In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The first is to use the decode, a very common way to write:
select sname,sum(decode(course,'language', score,0)) "language",sum(decode(course,' math', score,0)) "mathematics",sum(decode(course,'english', score,0)) "english" from score group by sname;
The second is a function pivot using oracle, which is a column rotation. There is also an unpivot, which is row to column.
select * from (select sname,course,score from score)
pivot(
sum(score)
for course in(
'language' as "language",
'mathematics' as 'mathematics,'
'English' as "English"))
order by sname;
Data source:
SNAME COURSE SCORE
-------------------
Bill Language 80
Bill Math 90
Bill English 92
Jim Language 78
Jim Maths 88
Jim English 98
Comparison of the two results:
SNAME Chinese Mathematics English
------------------------------
Bill 80 90 92
Jim 78 88 98
SNAME Chinese Mathematics English
-------------------------------
Bill 80 90 92
Jim 78 88 98
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.