Let's take one example to assign a sequential order, or rank, to people within a department based on salary, we might use the RANK function like.
SELECT employee_id,
department_id,
salary,
RANK() OVER (PARTITION BY department_id ORDER BY salary desc ) "rank"
FROM employees ;
SELECT employee_id,
department_id,
salary,
RANK() OVER (PARTITION BY department_id ORDER BY salary desc ) "rank"
FROM employees ;
0 comments:
Post a Comment