Bug #109295 ORDER BY col WITH ROLLUP
Submitted: 6 Dec 2022 10:24 Modified: 6 Dec 2022 19:16
Reporter: Michael Rushton Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:8 OS:Any
Assigned to: CPU Architecture:Any

[6 Dec 2022 10:24] Michael Rushton
Description:
The documentation on https://dev.mysql.com/doc/refman/8.0/en/select.html specifies that `ORDER BY` can have a `WITH ROLLUP` modifier:

[ORDER BY {col_name | expr | position}
      [ASC | DESC], ... [WITH ROLLUP]]

However this does not actually work, and there is no further explanation on it, and so I assume the documentation is wrong?

How to repeat:
See https://dev.mysql.com/doc/refman/8.0/en/select.html
[6 Dec 2022 10:33] MySQL Verification Team
Hello Michael Rushton,

Thank you for the report and feedback.

regards,
Umesh
[6 Dec 2022 17:21] Jon Stephens
Hi Michael,

The referenced page includes the following:

'Previously, it was not permitted to use ORDER BY in a query having a WITH ROLLUP modifier. This restriction is lifted as of MySQL 8.0.12. See Section 12.20.2, “GROUP BY Modifiers”.' 

This points to

https://dev.mysql.com/doc/refman/8.0/en/group-by-modifiers.html#group-by-modifiers-other-c...

which says

'As of MySQL 8.0.12, ORDER BY and ROLLUP can be used together, which enables the use of ORDER BY and GROUPING() to achieve a specific sort order of grouped results. [example follows]'

Please check the provided reference. If the does not work as shown there (WFM), please file a bug against the MySQL Server.

Thanks!

jon.
[6 Dec 2022 19:16] Michael Rushton
Hi Jon,

That appears to be saying that the following is allowed in 8:

GROUP BY col WITH ROLLUP ORDER BY col

In 5 You could only do:

GROUP BY col WITH ROLLUP

The issue is that I can't see any examples of this (which doesn't work in 8):

ORDER BY col WITH ROLLUP

If it should be allowed then I'll open a new bug against MySQL Server.