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!

Using Pivot Operator with percentages

bobmaganJul 22 2014 — edited Jul 22 2014

I am using Oracle 12c DB. I am trying to use the SQL pivot operator to give me a matrix output. I need to display 2 seperate outputs, one with counts and one with percents. I have the following SQL working to get me the counts, but I'm not exactly sure about the SQL for the percents. Please advise. Tx

with pivot_data as (select "score", "Observer_LastName", "profile_id"

                    from Mytable

                    where substr("Observer_LastName",1,1) = 'S')

SELECT *

from pivot_data

PIVOT (count("profile_id")

FOR "score" IN ('0','1','2','3')

)

This post has been answered by Frank Kulash on Jul 22 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2014
Added on Jul 22 2014
6 comments
741 views