2023/06 32

Leetcode 184 - Department Highest Salary

*** 다시 풀어볼 것 184. Department Highest Salary https://leetcode.com/problems/Department-Highest-Salary/ # 각각의 부서에서 누가 가장 고소득자인지 # sel 부서, 직원, 급여 # 순서 상관 x SELECT d.name AS Department , e.name AS Employee , e.salary AS Salary FROM employee as e INNER JOIN ( SELECT departmentID, MAX(salary) AS max_salary FROM Employee GROUP BY departmentID ) AS dh ON e.departmentID = dh.departmentID AND e.salary = dh..

Leetcode 180 - Consecutive Numbers

Consecutive Numbers https://leetcode.com/problems/consecutive-numbers/ # 최소 3번이상 연속적으로 나타나는 숫자 찾기 # 순서는 상관없음 SELECT DISTINCT l.num AS ConsecutiveNums -- 중복제거 FROM logs AS l INNER JOIN logs AS l_next ON l.id + 1 = l_next.id INNER JOIN logs AS l_next2 ON l.id + 2 = l_next2.id # three times consecutively WHERE l.num = l_next.num AND l_next.num = l_next2.num