| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- python
- SQL
- 프로그래머스
- 신입 데이터분석가
- pandas
- 그로스해킹
- Retention
- regexp
- 서브쿼리
- 린분석
- 리텐션
- 퍼널분석
- 데이터리안
- 취준
- advent of sql
- 윈도우 함수
- 독서
- row_number
- 순위함수
- dense_rank
- LEFTJOIN
- rank
- SolveSQL
- 누적합
- MYSQL
- 데이터분석
- funnel
- 윈도우함수
- Datarian
- leetcode
- Today
- Total
목록leetcode (19)
데이터 분석
문제 Write a solution to report the customer ids from the Customer table that bought all the products in the Product table. 모든 상품을 구매한 고객을 조회하는 문제이다. SolutionSELECT customer_idFROM CustomerGROUP BY customer_idHAVING COUNT(DISTINCT product_key) = (SELECT COUNT(product_key) FROM Product) ✅ 고객 id별 구매 이력이 있는 고유 상품 개수를 집계하여, 이것이 Product 테이블의 상품 개수와 동일한 경우를 만족하는 고객을 반환한다.
문제 Write a solution to find the people who have the most friends and the most friends number.The test cases are generated so that only one person has the most friends. 친구가 가장 많은 사람을 찾는 문제이다.단, 친구가 가장 많은 사람은 1명이다. Solution✔️ 쿼리 1WITH preprocessing AS (SELECT requester_id AS id , COUNT(*) AS numFROM RequestAcceptedGROUP BY requester_idUNION ALLSELECT accepter_id , COUNT(*) FROM RequestAcc..
문제 Write a solution to find managers with at least five direct reports. 5명 이상의 직속 부하 직원이 있는 관리자를 추출하는 문제이다. SolutuionSELECT nameFROM EmployeeWHERE id IN ( SELECT e.managerId FROM Employee e GROUP BY e.managerId HAVING COUNT(*) >= 5)
문제 Write a solution to report the fraction of players that logged in again on the day after the day they first logged in, rounded to 2 decimal places. In other words, you need to count the number of players that logged in for at least two consecutive days starting from their first login date, then divide that number by the total number of players. 전체 유저 중 최초 접속한 날을 기준으로 이틀 연속 접속한 플레이어의 비율을 계산하..
문제 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..