rank() analytic function
Oracle rank
As an analytic function, RANK computes the rank of each row returned from a query with respect to the other rows returned by the query, based on the values of the value_exprs in the order_by_clause.
返回工资第二高的员工
1 | SELECT * FROM ( |
verify result
1 | SELECT employee_id, last_name, salary, RANK() OVER (ORDER BY salary DESC) EMPRANK FROM employees; |
另外一个例子
1 | SELECT department_id,last_name,salary,commission_pct, |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 石头记!