我的 ROLLUP 有问题,我有空值的行,并且 ROLLUP 也返回 null,如何区分 ROLLUP 的空值和行的空值?
行中的空值存在是因为列 (group_name) 与左连接相关联。
这是我的查询:
SELECT gr.info,
HOUR(cdr.calldate) AS hour,
DATE(cdr.calldate) AS date,
COUNT(DISTINCT cdr.uniqueid) AS count,
pl.number,
IFNULL(ugr.group_name, "") AS group_name
FROM cdr
INNER JOIN callinfo AS ci
ON ci.uniqueid = cdr.uniqueid
LEFT JOIN users AS usr
ON usr.username = ci.agent
LEFT JOIN groups AS ugr
ON ugr.group_id = usr.group_id
INNER JOIN pstnline AS pl
ON ci.line = pl.number
INNER JOIN hunt_line AS gri
ON gri.pstnline_id = pl.pstnline_id
INNER JOIN hunt AS gr
ON gri.hunt_number = gr.number
WHERE cdr.calldate >='2012-12-01 00:00'
AND cdr.calldate <='2013-01-24 10:45'
GROUP BY group_name WITH ROLLUP
我看到在 SQL Server 中存在一个名为 GROUPING 的函数,但在 MySql 中不存在,我怎样才能达到相同的效果?