S
stvlai
Hi
How are you guys doing? I have a question about using SELECT and MAX
function. Say I have a Students Table with Fields StudentID,
FirstName, MiddleName, Score
StudentID FirstName MiddleName Score
1 John Doe 10
2 Mary Jane 20
3 Peter Smith 18
4 John Doe 30 ......
John's high score
5 Mary Jane 22
6 Peter Smith 30
7 John Doe 19
8 Mary Jane 25 ......
Mary's high score
9 Peter Smith 33 ......
Peter's high score
I use a Max statement to extract out each Student Max Score e.g
SELECT DISTINCTROW Max(Students.Number) AS [High Score],
Students.FirstName
FROM Students GROUP BY Students.FirstName;
Correct Results : John 30 Mary 25 Peter 33
Since I also need their Middle Name, I added their MiddleName field
too. BUT it return all the Rows (9 Records), which is NOT correct. e.g
SELECT DISTINCTROW Max(Students.Number) AS [Max Of Number],
Students.FirstName, Students.MiddleName FROM Students GROUP BY
Students.FirstName, Students.MiddleName;
How can I select each Student Score with their FirstName and
MiddleName?
Thanks for any suggestion.
Steven
How are you guys doing? I have a question about using SELECT and MAX
function. Say I have a Students Table with Fields StudentID,
FirstName, MiddleName, Score
StudentID FirstName MiddleName Score
1 John Doe 10
2 Mary Jane 20
3 Peter Smith 18
4 John Doe 30 ......
John's high score
5 Mary Jane 22
6 Peter Smith 30
7 John Doe 19
8 Mary Jane 25 ......
Mary's high score
9 Peter Smith 33 ......
Peter's high score
I use a Max statement to extract out each Student Max Score e.g
SELECT DISTINCTROW Max(Students.Number) AS [High Score],
Students.FirstName
FROM Students GROUP BY Students.FirstName;
Correct Results : John 30 Mary 25 Peter 33
Since I also need their Middle Name, I added their MiddleName field
too. BUT it return all the Rows (9 Records), which is NOT correct. e.g
SELECT DISTINCTROW Max(Students.Number) AS [Max Of Number],
Students.FirstName, Students.MiddleName FROM Students GROUP BY
Students.FirstName, Students.MiddleName;
How can I select each Student Score with their FirstName and
MiddleName?
Thanks for any suggestion.
Steven