I have two tables (MS Access)
tblInput
Event, UserID, Score EventA, 1, 50 EventA, 2, 55 EventB, 1, 45 EventB, 2, 33
tblUser
ID, Name 1 , John 2 , Alex
I need to show the winning score of each event, the event, and the name of the person. Output for this example should be
Event, Name, Score EventA, Alex, 55 EventB, John, 45
I have tried this to get the event and top score:
SELECT Max(Score), Event FROM tblInput GROUP BY Event;
However, if I try to select the ID (Which I’m just using in the place of name, can change back to name when I join tables), I am forced to make it an aggregate function which I don’t want to, or Place it in the Group by statement, which I get something like
SELECT Max(Score) AS Score, Event, ID FROM tblInput GROUP BY Event, ID;
Score, Event, ID 165 EventA 2 173 EventA 9 170 EventA 32 211 EventB 10 224 EventB 14 256 EventC 16 188 EventC 17
Any help is appreciated, sorry for poor formatting.
Create one query like this:
Then a second one built with the first query and your input table joined on both the event and score:
what if you have more than one user with the top score?
Like for event A, user 3 has a score of 55?