Bug #45648 | SELECT DISTINCT ... ORDER BY DESC returns wrong order | ||
---|---|---|---|
Submitted: | 22 Jun 2009 9:20 | Modified: | 22 Jun 2009 9:45 |
Reporter: | Richard Teubel | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: General | Severity: | S2 (Serious) |
Version: | 5.0.83 | OS: | Linux |
Assigned to: | CPU Architecture: | Any | |
Tags: | DESC, distinct, order by |
[22 Jun 2009 9:20]
Richard Teubel
[22 Jun 2009 9:45]
Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php You have 2 rows with field2 eq 'aa': (2,'aa','2009-04-04',1) and (3,'aa','2009-06-06',5). Optimizer is free to choose any of them when does DISTINCT, then order rows. Please read at http://dev.mysql.com/doc/refman/5.1/en/select.html: MySQL extends the use of GROUP BY to allow selecting fields that are not mentioned in the GROUP BY clause. If you are not getting the results that you expect from your query, please read the description of GROUP BY found in Section 11.12, “Functions and Modifiers for Use with GROUP BY Clauses”.