|
105ben
Starting Member
United Kingdom
16 Posts |
Posted - 12/29/2012 : 16:13:01
|
Hello,
the following query will find the total number of occurrences of every person_id in the attendance table, and list the figure and each person_id. Then when the second select runs to return the maximum and the person_id that has that maximum, its returning the maximum figure ok but then the person_id is just the first one in the count_temp table, regardless of which one has the highest total
select max(count), person_id from (select person_id, count(person_id) as count from attendance as a group by a.person_id) as count_temp
can anyone see why? |
|