How to convert pivot to unpivot in Oracle
It is believed that many inexperienced people do not know what to do about the conversion between pivot and unpivot in Oracle. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
A summary of today's answers to questions
Table:score (student number, Chinese, math, English, chemistry)
Student number Chinese mathematics English chemistry 1 pass excellent excellent fail 2 excellent pass excellent
One of the implementation methods:
Select * from (
With tt as (select * from score unpivot (cj for kc in ("Chinese", "Mathematics", "English", "Chemistry"))
Select "student number", kc
(case when cj > = 80 then 'excellent' when cj > = 60 then 'pass' else 'fail' end) cj
-- decode (sign (cj-80), 0dje 'excellent', 1dje 'excellent',-1dje decode (sign (cj-60), 0pr 'pass', 1pr 'pass', 1dre 'pass', 'fail') cj
From tt)
Pivot (max (cj) for kc in ('Chinese', 'Mathematics', 'English', 'Chemistry'))
After reading the above, have you mastered how to convert pivot to unpivot in Oracle? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!