Bug #6899 rollup as name
Submitted: 30 Nov 2004 23:17 Modified: 14 Jun 2013 0:11
Reporter: Randall Wiggins Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:4.1.7 OS:Any (Any)
Assigned to: CPU Architecture:Any

[30 Nov 2004 23:17] Randall Wiggins
Description:
with rollup returns NULL

How to repeat:
Just use with rollup as your group by modifier to get NULL back as the name of the count.

Suggested fix:
I use rollup often and it would be handy to assign specific text instead of the NULL it returns.

with rollup as 'Total Count'
[28 Mar 2008 17:37] Jorge Bernal
You can achieve similar results with something like this

SELECT IFNULL(Continent,"Total count") AS Continent, SUM(Population) FROM Country GROUP BY Continent WITH ROLLUP;
[19 Apr 2009 21:03] E Van den Boogaard
The manual has comments on this (see MySQL 5.1 on 11.12.2. GROUP BY Modifiers):
"There is one gotcha, if the column value itself has a NULL value, you may see undefined behavior." Examples used there: IFNULL(fieldname,"fieldData") and COALESCE(fieldname,"fieldData").