In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This "mysql sum (if ()) and count (if ()) how to use" the knowledge of the article most people do not understand, so the editor summarized the following content for you, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "mysql sum (if ()) and count (if ()) how to use" article.
The use of mysql sum (if ()) and count (if ()) SELECT SUM (if (category=1,size,0)), COUNT (if (category=1,true,null)) FORM tasking file; parsing sum (if (category=1,size,0))
The sum function returns a numeric value of value type, size if category=1, and 0 if category is not equal to 1.
Count (if (category=1,true,null))
The count function returns a value of Boolean type, if category=1, returns true, if category is not equal to 1, returns null, if written as count (If (category=1,1,0), all returns true, that is to say, all will be counted, while count () interruptions are true or null, count if it is not null, and do not count if it is null.
So count (if ()) should be written as count (if (expression expression, true,null)).
Mysql aggregate functions sum sum (if ()) SELECT p.Id Id, p.ImgUrl ImgUrl, p.Title Title, p.ReferOutPrice ReferOutPrice, e.`Status`, SUM (IF (e.`Status` = 1 OR e.`Status` = 2, ed.Number) according to conditions 0) FROM Product p LEFT JOIN EBOrdersDetails ed ON p.id = ed.ProductId LEFT JOIN EBOrders e ON ed.PurchaseNo = e.PurchaseNo WHERE p.StoreId = 143 AND p.`Status` >-1 GROUP BY p.Id
The above is about the content of this article on "how to use mysql sum (if ()) and count (if ())". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.