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!

Percentage Calculation

999670Jul 26 2017 — edited Jul 26 2017

Hi All,

I have the below example where i can calculate Percentage of individual values of the total value.

  WITH t1 AS (SELECT 1 as rnum,

                  5 AS value FROM DUAL

           UNION

           SELECT 2 as rnum,

                  10 AS value FROM DUAL

           UNION

           SELECT 3 as rnum,

                  15 AS value FROM DUAL

          )

select sum(t1.value), round(sum(t1.value)/sum(t2.total)*100,2)       

from t1,(select sum(value) as total from t1) t2

group by t1.rnum;

Can i achieve the same using some SQL Analytic function?

Thanks in advance.

This post has been answered by Gaz in Oz on Jul 26 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2017
Added on Jul 26 2017
5 comments
7,901 views