Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
layst
Starting Member
3 Posts |
Posted - 2011-04-25 : 08:08:45
|
| HELLO, I am having problems counting a particulat row from one table, while selecting multiple rows from two tables.I have two tables, One called STUDENT and another called RESULTS.I am trying to count the number of occurances a Student has an occurance of Assignment1Results. Here is what i have so far that i cant seem to get working.SELECT RESULTS.StudentID, STUDENT.StudentName, COUNT (RESULTS.StudentID)FROM STUDENT, RESULTSWHERE STUDENT.StudentID=RESULTS.StudentID AND REULTS.Assignment1Mark <> NULLORDER BY STUDENT.StudentName ASC;The error i get is You tried to execute a query that does not include the specified expression <name> as part of an aggregate function. (Error 3122)I have got it to count the total number, but im trying to relate it to each individual occurance of the StudentID which connects the two tables.Thanks in advance if you can helpBy the way im using Access 2007 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-04-25 : 08:12:44
|
| You just need to Group By RESULTS.StudentID, STUDENT.StudentNameand see if that gives you your expected results.JimEveryday I learn something that somebody else already knew |
 |
|
|
layst
Starting Member
3 Posts |
Posted - 2011-04-25 : 08:17:57
|
quote: Originally posted by jimf You just need to Group By RESULTS.StudentID, STUDENT.StudentNameand see if that gives you your expected results.JimEveryday I learn something that somebody else already knew
Thanks, Worked perfectly. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-04-25 : 08:23:19
|
| Your'e welcome. And welcome to SQL Team.JimEveryday I learn something that somebody else already knew |
 |
|
|
|
|
|