In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How to use having in SQL? In view of this problem, today the editor summarizes this article about having, hoping to help more friends who want to solve this problem to find a more simple and feasible way.
"having" is a statistical filter after "group by". Generally, "having" is used with "group by". When you use it, you need to group it first by "group by", and then carry out "having" statistical filtering, such as judging whether the value of the aggregate function is greater than a certain value.
SQL instance
First, display the total population and total area of each area.
SELECT region, SUM (population), SUM (area) FROM bbc GROUP BY region
First, the returned records are divided into groups with region, which is the literal meaning of GROUP BY. After the group is divided into groups, then use the aggregate function to compare each group
Perform operations on different fields (one or more records) of
Second, display the total population and total area of each region. Only those areas with an area over 1000000 are shown.
SELECT region, SUM (population), SUM (area) FROM bbcGROUP BY regionHAVING SUM (area) > 1000000
Here, we cannot use where to filter more than 1000000 regions, because such a record does not exist in the table.
On the contrary, the having clause allows us to filter groups of data
Mysql determines the length of a field:
Select home_page from aaa table where char_length (trim (home_page)) 1
So much for sharing the usage of having. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.