From a single table called 'student', I have an output like:
| Country | Subject | Level |
|---|---|---|
| France | History | 1 |
| France | Art | 1 |
| UK | History | 2 |
| France | History | 1 |
If all three columns match, I want to group them and count how many instances, so the above becomes:
| Country | Subject | Level | Count |
|---|---|---|---|
| France | History | 1 | 2 |
| France | Art | 1 | 1 |
| UK | History | 2 | 1 |
I could probably get the answer by putting the existing result in some mad PHP array, but I'd rather learn how to achieve it in MYSQL. Any tips on how to group by and count rows where multiple columns all match would be much appreciated. Thank you.