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

« Subselect help || Index Length »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home