[LeetCode Hard] 185. Department Top Three Salaries
·
SQL 문제 풀이
테이블 정보 문제 A company's executives are interested in seeing who earns the most money in each of the company's departments. A high earner in a department is an employee who has a salary in the top three unique salaries for that department. Write a solution to find the employees who are high earners in each of the departments. Return the result table in any order. The result format is in the followi..
[프로그래머스 Level 4] 입양 시각 구하기 (2)
·
SQL 문제 풀이
테이블 정보 문제보호소에서는 몇 시에 입양이 가장 활발하게 일어나는지 알아보려 합니다. 0시부터 23시까지, 각 시간대별로 입양이 몇 건이나 발생했는지 조회하는 SQL문을 작성해주세요. 이때 결과는 시간대 순으로 정렬해야 합니다.  결과 예시  문제 풀이 (MySQL)SET @HOUR = -1;SELECT (@HOUR := @HOUR + 1) AS HOUR, (SELECT COUNT(HOUR(B.DATETIME)) FROM ANIMAL_OUTS B WHERE @HOUR = HOUR(B.DATETIME) ) AS COUNTFROM ANIMAL_OUTS ALIMIT 24; 위에 예시를 보다시피 7시부터 데이터가 존재한다.그러므로 단순히 HOUR(DATET..