In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to achieve the combination and cumulative sorting of the fields in the table in SQL, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
The table is as follows:
1 10 12 2 2 9 8 2 3 12 8 3 1 9 9 3 1 12 0 3 2 5 18 2 2 20 0 2
All three fields are of type integer.
The requirements are as follows:
1. Search by index=2 2. Add all the same id together, and add the data together. 3. The final presented data should be sorted by in+out, from large to small.
To meet the above requirements: the SQL statement is designed as follows (assuming the table name is tab)
The code is as follows:
Select id,sum (in) as in,sum (out) as out from tab where index=2 group by id order by in + out desc
SQL on how to achieve the combination of fields in the table cumulative sorting is shared here, I hope that the above content can be of some help to you, can 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.