I have a MYSQL-Table which stores scores.
Every time a user improves a new entry is inserted into the table.
Example of the table:
| userID | time | gameID | |--------------------------| | u1 | 3 | game1 | | u1 | 2 | game1 | | u2 | 3 | game1 | | u3 | 3 | game1 | | u1 | 3 | game2 | | u2 | 1 | game2 |
I would like to query the table and get a table looking like this.
| gameID | min_time | avg_time | |--------------------------------| | game1 | 2 | 2.66 | | game2 | 1 | 2.00 |
I need the minimum time per gameID and the average time which only consists of each users minimum time per game (If a user played game1 three times only the best (shortest) should be used for the average with other users).
Is this possible with a MYSQL query?
1 Answer