Bug #17276 Unwanted behaviour WITH ROLLUP
Submitted: 9 Feb 2006 14:51 Modified: 23 Mar 2006 17:13
Reporter: John Baxter Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version: OS:
Assigned to: CPU Architecture:Any

[9 Feb 2006 14:51] John Baxter
Description:
Unwanted behaviour WITH ROLLUP.
---------------------------
The ROLLUP function performs unwanted aggregations on fields representing the same item.
For example:
SELECT idcountry, country, sum(something) AS val FROM country GROUP BY idcountry, country
will return:
idcountry       country        val
-----------------------------------------
1                 Austria        10
1                  NULL          10
2                 Belgium        15
2                  NULL          15
3                 Denmark        5
3                  NULL          5
NULL               NULL          30

If I remove the country field from the GROUP BY clause:
SELECT idcountry, country, sum(something) AS val FROM country GROUP BY idcountry
will return:
idcountry       country        val
-----------------------------------------
1                 Austria        10
2                 Belgium        15
3                 Denmark        5
NULL              Denmark        30

It would be very useful to be able to specify the fields you want to perform the ROLLUP on and not do it by default on all the fields included in the GROUP BY clause. 

How to repeat:
---
[23 Mar 2006 17:13] Valeriy Kravchuk
Thank you for a feature request. Sorry, but the feature you asked for will be implemented only in case of similar change to the SQL Standard.