SAMPLE:下例中计算每个员工按部门分区再按薪水排序,依次出现的序列号(注意与DENSE_RANK函数的区别)
SELECT d.department_id , e.last_name, e.salary, RANK() OVER (PARTITION BY e.department_id ORDER BY e.salary) as drank FROM employees e, departments d WHERE e.department_id = d.department_id AND d.department_id IN ('60', '90');
DEPARTMENT_ID LAST_NAME SALARY DRANK ------------- ------------------------- ---------- ---------- 60 Lorentz 4200 1 60 Austin 4800 2 60 Pataballa 4800 2 60 Ernst 6000 4 60 Hunold 9000 5 90 Kochhar 17000 1 90 De Haan 17000 1 90 King 24000 3
RATIO_TO_REPORT
|
功能描述:该函数计算expression/(sum(expression))的值,它给出相对于总数的百分比,即当前行对sum(expression)的贡献。
SAMPLE:下例计算每个员工的工资占该类员工总工资的百分比
SELECT last_name, salary, RATIO_TO_REPORT(salary) OVER () AS rr FROM employees WHERE job_id = 'PU_CLERK';
LAST_NAME SALARY RR ------------------------- ---------- ---------- Khoo 3100 .223021583 Baida 2900 .208633094 Tobias 2800 .201438849 Himuro 2600 .18705036 Colmenares 2500 .179856115
REGR_ (Linear Regression) Functions
|
功能描述:这些线性回归函数适合最小二乘法回归线,有9个不同的回归函数可使用。