Click to See Complete Forum and Search --> : SQL group by order by


l3asturd
March 11th, 2010, 03:38 PM
SELECT * FROM $dbTable GROUP BY xNAME ORDER BY xDATETIME DESC

What I am trying to do is extract only most recent entries for each unique xNAME. I can't figure out how to do this.

SO here is my example table:

john 8:00
greg 9:00
rick 10:00
john 10:15
rick 10:30
greg 11:00

and my desired result is:

john 10:15
greg 11:00
rick 10:30

Is this possible?

VictorN
March 11th, 2010, 05:00 PM
How about using Max(xDATETIME ?