MySQL GROUP BY & ORDER BY DESC

254 Views Asked by At

I have a table of checklists. These checklists have a name, type, version, and release. The requirement is to group the checklists by name and type, but give the latest release and version and release of that checklist. Here is my query so far:

SELECT 
    c.`name`, c.`type`, c.`ver`, c.`release`
FROM
    reference.checklist c
GROUP BY
    c.`name`
ORDER BY
    c.`name`, c.`ver` DESC, c.`release` DESC

The ordering doesn't work when I do it this way. I get the version and release in ASC order not DESC. If I remove the GROUP BY clause then the ordering is correct. Suggestions? TIA!

0

There are 0 best solutions below