I have a table structure like:
Name Time
Joe 2012-02-22 22:11:26.0
Joe 2012-02-22 21:01:23.0
Sue 2012-02-22 20:57:10.0
john 2012-02-22 18:13:36.0
Fred 2012-02-22 16:56:57.0
Joe 2012-02-22 14:38:45.0
Joe 2012-02-22 14:38:45.0
Ralph 2012-02-22 14:26:20.0
... ...
(more Names and Times)
... ...
john 2010-03-10 15:27:39.0
john 2010-03-10 15:46:59.0
I'm looking for the Top 3 Names Ordered by Time. So the result would be:
Joe, Sue, john
I began with a query like:
SELECT Name FROM table ORDER BY LOWER(TIME) DESC
So I wanted to Limit the result with:
SELECT Name FROM table ORDER BY LOWER(TIME) DESC LIMIT 0 , 3
But the result shows the first 3 rows as aspected:
Joe, Joe, Sue
Now I'm trying to group the query by Name first:
SELECT Name FROM table GROUP BY Name ORDER BY LOWER(TIME) DESC LIMIT 0 , 3
And yes that gives me 3 different names but in a unreproducible order. Am I missing something here? What would be the correct syntax here?