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--
Construct tables and data
CREATE TABLE Sales (Year INTEGER,Quarter INTEGER,Results INTEGER)
Insert into sales values (2005. 4. 27)
Insert into sales values (2005, 3, and 12)
Insert into sales values (2005Jing 2jue 40)
Insert into sales values (2005 Jing 1 Ji 18)
Insert into sales values (2004, 4, 10)
Insert into sales values (2004jue 3jue 15)
Insert into sales values (2004Jing 2jue 30)
Insert into sales values (2004 Jing 1 Jue 20)
Select * from sales order by year,quarter
YEAR QUARTER RESULTS
-
2004 1 20
2004 2 30
2004 3 15
2004 4 10
2005 1 18
2005 2 40
2005 3 12
2005 4 27
If you want to change to the following look
YEAR Q1 Q2 Q3 Q4
-
2004 20 30 15 10
2005 18 40 12 27
Convert SQL
SELECT Year
, MAX (CASE
WHEN Quarter = 1
THEN Results
END) AS Q1
, MAX (CASE
WHEN Quarter = 2
THEN Results
END) AS Q2
, MAX (CASE
WHEN Quarter = 3
THEN Results
END) AS Q3
, MAX (CASE
WHEN Quarter = 4
THEN Results
END) AS Q4
FROM Sales
GROUP BY YEAR
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.