Data:
Name | Score | Date
==
John | 10 | 09/01/2012
John | 20 | 09/01/2012
John | 5 | 09/01/2012
Frank | 20 | 11/01/2012
I want to run an SQL statement that will pull only the highest score from each day only, so I don’t want three scores from one date, only the highest. So the return I’d like from SQL would be:
John | 20 | 09/01/2012
Frank | 20 | 11/01/2012
Is it possible to do this via SQL, currently I can do it after pulling everything by checking dates. But would be great if it’s possible to do it direct from the DB.
I have tried a few solutions but as Date and Score aren’t distinct, as I want the highest I am unsure of where to proceed. The SQL is being used with a MS Access database.
Here’s a complete example. I did it in Oracle, so you might have to tweak the syntax a bit for Access.
Output:
Note that if two people have highest score for given day, it will print them both. For example:
Output: