I need query to get the count of participants in each level.
Note: participant who is in level 4 should not be in other levels ex: Level 3,2,1. I.e. I'm only interested in the highest level of each participant.
Table :
+----+-------+----------+
| ID | Level | Date |
+----+-------+----------+
| 38 | 1 | 06 -05 |
| 38 | 2 | 08 -05 |
| 38 | 3 | 12 -05 |
| 38 | 4 | 13 -05 |
| 39 | 1 | 13 -05 |
| 39 | 2 | 13 -05 |
| 40 | 1 | 12 -05 |
+----+-------+----------+
Needed Output:
+-------+-------+
| Count | Level |
+-------+-------+
| 1 | 1 |
| 1 | 2 |
| 0 | 3 |
| 1 | 4 |
+-------+-------+