I have a table like this:
id| name | attendence
1 | Naveed| 1
2 | Naveed| 1
3 | Adil | 1
4 | Adil | 1
I use following query:
SELECT * FROM `test` WHERE `attendence`=1 GROUP BY name
The result with above query:
id| name | attendence
3 | Adil | 1
1 | Naveed | 1
Question:
Above result group rows by name but show first row from each group. I want to select last row(by id) from each group.
For example:
id| name | attendence
2 | Naveed | 1
4 | Adil | 1
How to write query for above result.
Thanks