Ranking Window Functions and Joins
Can a solution for question 2 in this assignment be this:
SELECT
e.emp_no,
DENSE_RANK() OVER w as employee_salary_ranking,
s.salary,
e.hire_date,
s.from_date,
(YEAR(s.from_date) - YEAR(e.hire_date)) AS years_from_start
FROM
employees e
JOIN
salaries s ON s.emp_no = e.emp_no
WHERE e.emp_no BETWEEN 10500 AND 10600
AND YEAR(s.from_date) - YEAR(e.hire_date) >= 5
WINDOW w as (PARTITION BY e.emp_no ORDER BY s.salary DESC);
The difference between this and the provided solution is the position of the AND clause. Here is it in the WHERE statement instead of the JOIN
0 answers ( 0 marked as helpful)