ORDER BY with GROUP BY
Date: 01/16/08
(MySQL Communtiy) Keywords: no keywords
xvar xnum
abc 1a
abc 2b
abc 3c
wer 2a
sdf 3b
sdf 2c
SELECT xvar, xnum FROM table GROUP BY xvar
results:
abc 1a
wer 2a
sdf 3b
SELECT xvar, xnum FROM table GROUP BY xvar ORDER BY xnum DESC
results:
abc 1a
wer 2a
sdf 3b
How do I sort the grouped columns? I need this:
abc 3c
wer 2a
sdf 3b
Source: http://community.livejournal.com/mysql/123155.html