将 NULL 值从 ROLL UP FUNCTION 更改为 TOTAL

Change NULL value to TOTAL from ROLL UP FUNCTION

美好的一天 我尝试将 NULL 的值从汇总函数更改为 null 但我收到

错误

GROUPING FUNCTION DOES NOT EXIST

。请检查下面我的代码。

 SELECT
    CASE
WHEN GROUPING (`ProductName`) = 1 THEN
    'TOTAL'
ELSE
    CAST(`ProductName` AS VARCHAR(10))
END `ProductName`,
 SUM(`Quantity`),
 SUM(`Price Paid`)
FROM
    `bacoor_products`
GROUP BY
    `ProductName` WITH ROLLUP

mysql中没有分组功能,但您可以按照下面的方法尝试-

SELECT IFNULL(`ProductName`, 'Total') AS 'ProductName', SUM(`Quantity`), 
SUM(`Price Paid`) FROM `bacoor_products` GROUP BY `ProductName` WITH ROLLUP