Window Function

    Department Top Three Salaries [ MSSQL ]

    Department Top Three Salaries - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com WINDOW 함수인 DENSE_RANK()를 사용하여 동일한 값은 동일한 랭크를 주게 하였고 SELECT 절에 연산한 것을 WHERE절에서 필터링 조건으로 사용할 수 없기 때문에 서브쿼리로 묶어 값을 뽑아냈습니다. SELECT t.department, t.employee, t.salary FROM ( SELECT d.name AS department , e.n..

    Department Highest Salary [ MSSQL ]

    Department Highest Salary - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com WINDOW FUNCTION을 사용해 departmentId 기준으로 그룹을 묶어 max_salary값을 구한 후 FROM절 서브쿼리를 사용해 max_salary와 같은 salary를 갖고있는 row만 추출했습니다. SELECT Department , Employee , Salary FROM ( SELECT d.name AS Department , e.name AS ..