In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use a SQL statement to remove the same data in two tables and then accumulate the same data in the third table". The content in the article is simple and clear, and it is easy to learn and understand. below, please follow the editor's train of thought to study and learn "how to use a SQL statement to remove the same data in two tables and accumulate the same data in the third table".
Table X:
A B C D
-
Beijing Guangzhou 1000 10
Beijing and Shenzhen 1200 20
Beijing and Shanghai 500 30
Beijing Tianjin 300 40
Beijing Henan 800 20
Table Y:
A B
-
Beijing and Shenzhen
Beijing and Shanghai
Table Z:
A B C D
-
Beijing Guangzhou 200 10
Beijing and Shanghai-100-10
Beijing Sichuan 800 50
Objective: to remove the data with the same keyword in Table Y from Table X, and add the data in Table Z to accumulate the same keyword (AMagi B is the keyword).
The results are as follows:
A B C D
-
Beijing Guangzhou 1200 20
Beijing and Shanghai 400 20
Beijing Henan 800 20
Beijing Sichuan 800 50
The copy code is as follows:
Select an as d from bstatement sum (c) as c
(select * from x union all select * from z) t
Where not exits (select 1 from y where y.a=t.an and y.b=t.b)
Group by a,b
Thank you for your reading, the above is "how to use a SQL statement to remove the same data in two tables and then accumulate the same data in the third table". After the study of this article, I believe you have a deeper understanding of how to use a SQL statement to remove the same data in two tables and accumulate the same data in the third table. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.