Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / May 2008

Tip: Looking for answers? Try searching our database.

Select & Max Function Q

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
stvlai - 13 May 2008 18:00 GMT
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
Duane Hookom - 13 May 2008 20:51 GMT
Try:

SELECT Max(Students.Number) AS [Max Of Number],
Students.FirstName, Students.MiddleName
FROM Students
GROUP BY
Students.FirstName, Students.MiddleName;

Signature

Duane Hookom
Microsoft Access MVP

> Hi
>
[quoted text clipped - 35 lines]
>
> Steven
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.