In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
What is the principle of cumulative aggregation in the MySQL database? many novices are not very clear about it. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
Cumulative gathering
Cumulative aggregation is the aggregation of data from the first element in the sequence to the current element, such as returning the number of orders accumulated from the beginning of each month to now and the average number of orders for each employee.
There are two solutions to the line number problem, which are to use subqueries and to use joins. The method of subquery is usually intuitive and readable. However, when aggregation is required, the subquery needs to scan the data once for each aggregation, while the join method usually only needs to scan once to get the results.
The following query uses joins to get the results
SELECTa.empid,a.ordermonth,a.qty AS thismonth,SUM (b.qty) AS total,CAST (AVG (b.qty) AS DECIMAL (5pm 2)) AS avgFROM emporders an INNER JOIN emporders bON a.empid=b.empidAND b.ordermonth
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.