Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unpivot to get a description, Sum and Count

Richard LeggeOct 19 2020 — edited Oct 19 2020

Hi All,
Given the following:
select sum(col1), count(col1), sum(col2), count(col2) , sum(col3), count(col3) from table
how can I unpivot so that I get the following:
Description sum count
col1 _name sum_col1 count_col1
col2_name sum_col2 count_col2
col3_name sum_col3 count_col3

My thinking is that somehow I need to create a pseudo group name for the columns, and I want to avoid using a union clause to get the data separately
Thanks

This post has been answered by Frank Kulash on Oct 19 2020
Jump to Answer
Comments
Post Details
Added on Oct 19 2020
9 comments
1,919 views