I am a bit stuck on how to get all the rows I want from the max count of one column, grouping by only some specific columns. For example, over here I want to group by user and name so that they are always distinct. But for country and device type I only want the combination of their max event_ct to show up
| user | name | country | device | event_ct |
|---|---|---|---|---|
| 5 | Albert | US | Mac | 5 |
| 5 | Albert | GB | Phone | 7 |
| 5 | Albert | CN | Mac | 3 |
| 6 | Albert | CN | Mac | 1 |
| 7 | Laurel | US | Phone | 7 |
I want a mysql query to turn it into
| user | name | country | device |
|---|---|---|---|
| 5 | Albert | GB | Phone |
| 6 | Albert | CN | Mac |
| 7 | Laurel | US | Phone |
Please help! Thanks :-)