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; 

dbfiddle demo

output:

departmentid total_percentage 1            66.66 2            100 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -