SQL: Leet code 문제풀이(570, 1934, 620)
·
DATA/SQL
570. Managers with at least 5 direct reports https://leetcode.com/problems/managers-with-at-least-5-direct-reports/description/ #구할 값: name # 조건절에서 managerId가 5번 이상 언급되는 값을 찾아서 집계해준다.select namefrom Employeewhere id in (select managerId from Employee group by managerId having count(*) >= 5)  1934. Confirmation Ratehttps://leetcode.com/problems/confirmation-rate/description/ 각 사용자의 확..
SQL풀이: Leetcode 1661. Average Time of Process per Machine
·
DATA/SQL
https://leetcode.com/problems/average-time-of-process-per-machine/ 문제machine_id와 기계 종류별로 처리 평균 시간을 구하면 되는 문제로 평균 시간은 소수 3째자리에서 반올림해주어야 한다. 방법1 select machine_id, round(sum(case when activity_type = 'start' then - timestamp else timestamp end) / count(distinct process_id), 3) as processing_timefrom Activitygroup by machine_id; 방법2테이블을 두 개로 분리해서 푸는 방법SELECT a.machine_id, ROUND(AVG(b...