"MySQL" MySQL statistics null field processing

Source: Internet
Author: User

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 joins 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 the full orders of yo u! \033[0m "

"MySQL" MySQL statistics null field processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.