IFNULL 函数在 MySQL 查询中不起作用

IFNULL Function is Not Working in MySQL Query

我要 Grand Total 的运算符。但是 IFNULL 功能不起作用。

SELECT 
      IFNULL(op.operator_name, "Grand Total") AS operator, 
      SUM(re.amount) AS amount 
FROM mobile_db.recharge re 
INNER JOIN mobile_db.operator op 
ON re.operator_id = op.operator_id
GROUP BY operator WITH ROLLUP

您不能将 ALIAS 用作 GROUP BY 参数。在下面尝试我的查询:

SELECT 
     IFNULL(op.operator_name, "Grand Total") AS operator, 
     sum(re.amount) AS amount 
FROM mobile_db.recharge re 
INNER JOIN mobile_db.operator op ON re.operator_id = op.operator_id
GROUP BY IFNULL(op.operator_name, "Grand Total") WITH ROLLUP