sql - Calculate percentage rows over some specific value -
is there oracle function me calculate percentage of rows accepts condition
example table:
workerid salary departmentid 10001 2000.00 1 10002 2500.00 2 10004 3000.00 1 10005 3500.00 1
i know percentage of workers have salary on 2100.00 per each department
you use ratio_to_report
:
select departmentid, 100 * sum(rr) total_percentage (select t.*, ratio_to_report(1) on (partition departmentid) rr your_tab t) s salary > 2100 group departmentid;
output:
departmentid total_percentage 1 66.66 2 100
Comments
Post a Comment