I have one table with data about attendance into some events. I have in the table the data of the attendance everytime the user sends new attendance, the information is like
Here is one option (untested):
SELECT v.id_branch_channel, v.id_member, v.attendance, v.timestamp, v.id_member
FROM view_event_attendance v
JOIN (
SELECT id_event, id_member, MAX(attendance) maxattendance
FROM view_event_attendance
GROUP BY id_event, id_member ) m ON
v.id_event = m.id_event AND
v.id_member = m.id_member AND
v.attendance = m.maxattendance
WHERE v.id_event = 782
GROUP BY v.id_member;
The concept is to get the MAX()
of timestamp and use that field to JOIN
on your view. You might not need all the fields -- really depends on your table structure. But this should get you going in the correct direction.