
Round(ratio_to_report(sal) OVER (PARTITION BY e.deptno),2) sal_dept_ratio,

You’ll notice that you can calculate the same value using a different method ( sal_dept_ratio2) which may be why I haven’t seen RATIO_TO_REPORT used that often. The following example shows the percentage of each employees salary when compared to the sum of their department’s salary. RATIO_TO_REPORT compares the current value against the sum of the other set of values. The Oracle analytic function documentation can be found here. It’s by far the best article I’ve read at explaining what analytic functions are and how to use them. If you’ve never heard of or used Oracle analytic functions please read this article first.


I thought it would be a good idea to do a quick blog post on these analytic functions. I had to write some reports for a personal application of mine last night and needed to expand beyond my usual set of analytic functions that I normally use.
