Alex K Wrote:
-------------------------------------------------------
> I don't use object_id anywhere else because I
> don't care which object it was. I just want to
> make sure that only the latest person to access
> each object gets credit.
I do not think you can achieve that with a GROUP BY. For columns that
are not part of the GROUP BY expression, no guarantees are given as to
which of the rows in the group the values are selected from.
Ref.
http://dev.mysql.com/doc/refman/5.5/en/group-by-hidden-columns.html:
When using this feature, all rows in each group should have the
same values for the columns that are ommitted from the GROUP BY
part. The server is free to return any value from the group, so
the results are indeterminate unless all values are the same.
> The innermost query sorts all the of the events by
> date (most recent first). The query outside that
> uses the group by trick to select only the first
> event for each object. The outermost query then
> counts up how many per person.
That the group by query returns the first row from the result set of
the subquery, is an implementation detail that may change in future
versions without further notice.
Regards,
Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway