Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

group by and order by trouble

0 views
Skip to first unread message

Iain Adams

unread,
Nov 23, 2006, 8:27:53 AM11/23/06
to
hey,

I have a table with some columns, 2 of which are eventTime and gameId.
gameId however is not the primary key and is not unique for each
record, that is id. I want to get returned all the unique gameId's the
biggest eventTime for that gameId. Then order then by the returned
eventTime. I have tried numerous possibilities but cannot seem to get
this to work. If anybody knows please can you reply

Captain Paralytic

unread,
Nov 23, 2006, 9:45:31 AM11/23/06
to

Something like this (what I call the Strawberry query) perhaps:

SELECT g1. *
FROM `games` g1
LEFT JOIN `games` g2 ON g1.`gameId` = g2.`gameId` AND g1.`eventTime` <
g2.`eventTime`
WHERE g2.`eventTime` IS NULL
ORDER BY g1.`eventTime`

0 new messages