mysql统计当前列的总和
mysql查询出来的sum后,想要统计整个的总和。
下面这个函数能直接实现这个功能
SELECTifnull(domain_name,"TOTAL"),
count(id),
sum(CASE WHEN failed_comments = "getTokenError" THEN 1 else 0 END) get_token_error,
sum(CASE WHEN failed_comments = "loginError" THEN 1 else 0 END) login_error,
sum(CASE WHEN failed_comments = "fetchError" THEN 1 else 0 END) fetch_error,
sum(CASE WHEN failed_comments = "talkError" THEN 1 else 0 END) talk_error,
sum(CASE WHEN failed_comments = "logoutError" THEN 1 else 0 END) logout_error,
sum(CASE WHEN failed_comments = "domainError" THEN 1 else 0 END) domain_error,
sum(CASE WHEN failed_comments = "intentError" THEN 1 else 0 END) intent_error
FROM
%s
WHERE
task_id = %d
GROUP BY
domain_name with rollup;
with rollup 这个函数,可以统计
以上是 mysql统计当前列的总和 的全部内容, 来源链接: utcz.com/z/512075.html