Thank you for your help! If the status of the bug report you submitted changes,
you will be notified. You may return here and check on the status or update
your report at any time. That URL for your bug report is: http://bugs.mysql.com/38061.
Bug #38061 | select from view w/group by ignores view order | ||
---|---|---|---|
Submitted: | 11 Jul 2008 21:16 | Modified: | 14 Jul 2008 2:35 |
Reporter: | Derek Price | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Views | Severity: | S2 (Serious) |
Version: | 5.0.51a | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | view group by order by |
[11 Jul 2008 21:16]
Derek Price
[13 Jul 2008 4:37]
MySQL Verification Team
Thank you for the bug report. How Giuseppe already commented: This is expected behavior. http://dev.mysql.com/doc/refman/5.0/en/select.html "If you use GROUP BY, output rows are sorted according to the GROUP BY columns as if you had an ORDER BY for the same columns." "If ORDER BY occurs within a subquery and also is applied in the outer query, the outermost ORDER BY takes precedence. " The above statements mean that you are sorting by subkey, which has duplicates. In case of two rows having the same value in the sorting column, the returned row is not guaranteed to be in any specific order.
[14 Jul 2008 2:35]
Derek Price
Okay, I guess the previous version of our application was relying on undocumented/unspecified behavior in previous MySQL versions. Anyhow, I've worked out a work around already, so it's no skin off my back. Thanks.