| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
- 독서
- Datarian
- 윈도우 함수
- rank
- 누적합
- 취준
- 데이터리안
- python
- 리텐션
- regexp
- row_number
- 퍼널분석
- SQL
- LEFTJOIN
- 순위함수
- 프로그래머스
- 신입 데이터분석가
- 윈도우함수
- MYSQL
- advent of sql
- Retention
- 그로스해킹
- leetcode
- pandas
- dense_rank
- funnel
- 서브쿼리
- 린분석
- SolveSQL
- 데이터분석
- Today
- Total
목록SQL/leetcode (25)
데이터 분석
문제 Write a solution to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between "2013-10-01" and "2013-10-03". Round Cancellation Rate to two decimal points. 일별 Cancellation Rate은 '취소 건수 / 요청 건수'와 같이 계산한다.단, client와 driver 모두 banned = 'No' 조건을 만족하는 경우만 고려한다. SolutionSELECT t.request_at AS Day , ROUND(COUNT(CASE ..
문제 Write a solution to find employees who have the highest salary in each of the departments.Return the result table in any order. 부서별 최고 급여를 갖는 직원의 부서명, 이름, 급여를 조회하는 문제이다.📢동일한 최고 급여를 가진 경우 모두 출력해야 하기 때문에 순위함수 중 ROW_NUMBER 함수는 사용해서는 안 된다. Solution ✅ WHERE절 다중 컬럼 서브쿼리를 활용WITH highest AS ( SELECT departmentID , MAX(salary) FROM Employee GROUP BY departmentID)SELECT d.name AS Dep..
문제 Write a solution to find the employees who earn more than their managers.Return the result table in any order. 본인의 매니저보다 급여가 높은 직원의 이름을 조회하는 문제이다.Joe의 salary 옆에 Sam의 salary를 붙여놓고 비교하는 방식으로 접근하면 해결할 수 있을 것이다. Solution ✅ 동일한 두 테이블을 SELF-JOIN하여 접근한다. ● e1 테이블은 기존에 기록된 직원들의 정보를 알기 위해 사용● e2 테이블은 기존에 기록된 직원들의 매니저 정보를 알기 위해 사용SELECT e.name AS EmployeeFROM Employee e JOIN Employee m ON e.manager..
문제Write a solution to find all customers who never order anything. Return the result table in any order. 주문 이력이 없는 고객을 조회하는 문제이다. SolutionSELECT c.name AS CustomersFROM Customers c LEFT JOIN Orders o ON c.id = o.customerID WHERE o.customerID IS NULL/*SELECT name AS CustomersFROM Customers WHERE id NOT IN (SELECT DISTINCT customerId FROM Orders)*/ ● Customers 테이블의 모든 행을 유지하면서, Orders 테이블에서 일치..
문제 Reformat the table such that there is a department id column and a revenue column for each month. Return the result table in any order. Solution ✅ 제공 테이블의 id, month, revenue 데이터를 가지고, 각 month를 열로 변환하여 revenue 데이터를 각 열에 맞게 매핑해야 하는 문제이다. 👉 CASE문과 집계 함수(MAX, SUM, ... )를 조합하여 피봇 테이블을 구현한다. ● 1 SELECT id , MAX(CASE WHEN month = 'Jan' THEN revenue END) AS Jan_Revenue , MAX(CASE WHEN month..