I have a view with a lot of data. I can got this results using subqueries (data that is ok and optimized):
+------------+
| attendance |
+------------+
|        319 |
|        102 |
|        598 |
|        113 |
|          6 |
|        279 |
|        366 |
|        146 |
|        669 |
|        205 |
|        123 |
+------------+
The next time some user update data, it shows this:
+------------+
| attendance |
+------------+
|        319 |
|        102 |
|        598 |
|        113 |
|          7 |
|        279 |
|        253 |
|        146 |
|        669 |
|        561 |
|        123 |
+------------+
Which is ok, 'cause the user that update the information was the one that before has 6 as attendance.
But the problem comes when I use that data as a temptable and then I make:
 SELECT SUM(attendance) AS total FROM ( /* Subquery returning the above table */)
cause it returns (in the first place with one user having 6 as attendance):
+-------+
| total |
+-------+
|  3169 |
+-------+
And with 7:
+-------+
| total |
+-------+
|  3128 |
+-------+
When it should be 3170!!!
Ideas?
EDIT 1: Pasting the full query.
SELECT SUM(att_member) AS total
FROM
    (SELECT attendance AS att_member
     FROM
         (SELECT id_branch_channel, id_member, attendance, TIMESTAMP, id_event
          FROM view_event_attendance
          WHERE id_event = 782
          ORDER BY TIMESTAMP DESC) AS temptable
     GROUP BY 
              id_member) AS total_attendance_temp
EDIT 2: Pasting the query help I got from here
Select only last value using group by at mysql
Here is the schema of the view.
 
     
    