MySQLMySQL统计NULL字段处理
Posted junneyang 的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQLMySQL统计NULL字段处理相关的知识,希望对你有一定的参考价值。
select A.user_id,ifnull(sum(ifnull(A.ex_cpu,0)),0) AS a0, ifnull(sum(ifnull(A.ex_mem,0)),0) AS a1, ifnull(sum(ifnull(A.ex_disk,0)),0) AS a2, ifnull(sum(ifnull(B.cpu,0)),0) AS a3, ifnull(sum(ifnull(B.mem,0)),0) AS a4, ifnull(sum(ifnull(B.disk,0)),0) AS a5 from tbl_service_instance as A left join tbl_service_spec as B on A.service_spec_id = B.id where A.env_id ="84d97900-8d24-4904-984e-e49d6809e3af" and A.project_id ="6fe742d2-c872-4292-bb03-bf1af481cb4d " and A.status != 2 and A.status != 3 group by A.user_id;
select A.user_id, ifnull(sum(ifnull(A.ex_cpu,0)),0)+ifnull(sum(ifnull(B.cpu,0)),0) AS aaa, ifnull(sum(ifnull(A.ex_mem,0)),0)+ifnull(sum(ifnull(B.mem,0)),0) AS bbb, ifnull(sum(ifnull(A.ex_disk,0)),0)+ifnull(sum(ifnull(B.disk,0)),0) AS total from tbl_service_instance as A left join tbl_service_spec as B on A.service_spec_id = B.id where A.env_id = "84d97900-8d24-4904-984e-e49d6809e3af" and A.project_id = "6fe742d2-c872-4292-bb03-bf1af481cb4d" and A.status != 2 and A.status != 3 group by user_id ORDER BY total DESC LIMIT 5;
cd /opt/java/workspace/xproject && echo -e "\033[32mWarmly welcome, My honored master, I‘ll take full orders of you! \033[0m"
以上是关于MySQLMySQL统计NULL字段处理的主要内容,如果未能解决你的问题,请参考以下文章