id| name | attendence
1 | Naveed| 1
2 | Naveed| 1
3 | Adil | 1
4 | Adil | 1
SELECT MAX("id"), "name" FROM "test" WHERE "attendence" = 1 GROUP BY "name"
select * from (SELECT * from test order by id desc) as t WHERE "attendence" = 1 GROUP BY "name"
References :
php - SQL: GROUP BY records and then get last record from each group? - Stack Overflow
沒有留言:
張貼留言