I would like to query the ranking for the on highest point, if the point is the same, check the time to complete is the shortest. my table is
+-------------------------------------------------+
| | id | user_id | point | finishtime | week | |
+-------------------------------------------------+
| | 1 | G1 | 1560 | 55 | 1 | |
| | 2 | G1 | 1560 | 43 | 1 | |
| | 3 | G1 | 1530 | 55 | 1 | |
| | 4 | G2 | 1760 | 45 | 1 | |
| | 5 | G3 | 1760 | 46 | 1 | |
| | 6 | G3 | 1330 | 25 | 2 | |
| | 7 | G4 | 360 | 65 | 1 | |
| | 8 | G2 | 1760 | 50 | 1 | |
Expected result is
+-------------------------------------------------+
| | id | user_id | point | finishtime | week | |
+-------------------------------------------------+
| | 4 | G2 | 1760 | 45 | 1 | |
| | 5 | G3 | 1760 | 46 | 1 | |
| | 2 | G1 | 1560 | 43 | 1 | |
| | 7 | G4 | 360 | 65 | 1 | |
| | 6 | G3 | 1330 | 25 | 2 | |
I tried select max for the point, but it won't take the shortest finishtime.
I need the result group by unique user_id, get the order by highest point, and shortest finishtime.
Am I need to use if else statement?