In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how mysql to achieve cumulative summation, the article is very detailed, has a certain reference value, interested friends must read it!
mysql method to achieve cumulative sum: 1, create a data table;2, insert data;3, by "SELECT a.id, a.money,SUM(lt.money) as cum... "The statement can be accumulated.
Operating environment: Windows 7 system, mysql version 5.5, Dell G3 computer.
mysql cumulative sum:
There are the following tables
id
money
1
10
2
20
3
30
4
40
Find the following data
id
money
cum
1
10
10
2
20
30
3
30
60
4
40
100
table creation
CREATE TABLE cum_demo(id INT,money INT,PRIMARY KEY (id))
insert data
insert into cum_demo(id,money)values (1,10),(2,20),(3,30),(4.40);
accumulation
SELECT a.id,a.money,SUM(lt.money) as cumFROM cum_demo a JOIN cum_demo lt ON a.id >= lt.idGROUP BY a.moneyORDER BY id
results
idmoneycum110102203033060440100 Above is "mysql how to achieve cumulative sum" All the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to 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.
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.