| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- 누적합
- 리텐션
- 린분석
- pandas
- 순위함수
- dense_rank
- row_number
- SolveSQL
- LEFTJOIN
- advent of sql
- rank
- 프로그래머스
- 독서
- 취준
- leetcode
- MYSQL
- Datarian
- 서브쿼리
- 신입 데이터분석가
- 그로스해킹
- regexp
- 데이터분석
- Retention
- 데이터리안
- SQL
- 윈도우함수
- 윈도우 함수
- 퍼널분석
- python
- funnel
- Today
- Total
목록SQL/leetcode (25)
데이터 분석
문제 Write a solution to find the sum of amounts for odd and even transactions for each day. If there are no odd or even transactions for a specific date, display as 0. Return the result table ordered by transaction_date in ascending order. 💡각 일자별로 amount 값이 홀수인 경우의 합, 짝수인 경우의 합을 집계하는 문제 SolutionSELECT transaction_date , IFNULL(SUM(CASE WHEN MOD(amount, 2) != 0 THEN amount END), 0) AS odd_su..
문제 A subscription service wants to analyze user behavior patterns. The company offers a 7-day free trial, after which users can subscribe to a paid plan or cancel. Write a solution to:Find users who converted from free trial to paid subscriptionCalculate each user's average daily activity duration during their free trial period (rounded to 2 decimal places)Calculate each user's average daily ac..
문제 Biologists are studying basic patterns in DNA sequences. Write a solution to identify sample_id with the following patterns:Sequences that start with ATG (a common start codon)Sequences that end with either TAA, TAG, or TGA (stop codons)Sequences containing the motif ATAT (a simple repeated pattern)Sequences that have at least 3 consecutive G (like GGG or GGGG)Return the result table ordered ..
문제 Write a solution to find the students who have shown improvement. A student is considered to have shown improvement if they meet both of these conditions: Have taken exams in the same subject on at least two different dates.Their latest score in that subject is higher than their first score.Return the result table ordered by student_id, subject in ascending order. 다음 조건을 만족하면 성적이 향상된 학생으로 판단..
문제 Write a solution to find all the pairs (actor_id, director_id) where the actor has cooperated with the director at least three times. 3번 이상 협업한 적이 있는 actor_id, director_id 쌍을 조회하는 문제이다. SolutionSELECT actor_id, director_idFROM ActorDirectorGROUP BY actor_id, director_idHAVING COUNT(*) >=3 ✅ (actor_id, director_id) 기준으로 해당 조합이 등장한 횟수를 집계하여, 3 이상인 쌍만 결과에 포함하는 간단한 쿼리! https://hwangbyeongho.t..
문제 Write a solution to find the names of all the salespersons who did not have any orders related to the company with the name "RED". "RED"라는 이름의 회사와 관련된 주문이 전혀 없는 모든 영업사원의 이름을 조회하는 문제이다. 💡여사건 개념을 떠올린다‼️"RED" 회사와 관련된 주문을 한 영업사원을 제외한 나머지를 조회. SolutionSELECT nameFROM SalesPersonWHERE sales_id NOT IN ( -- 그렇지 않은 사원 SELECT o.sales_id -- "RED" 회사와 관련된 주문을 한 사원 FROM Orders o LEFT ..
문제Write a solution to find the customer_number for the customer who has placed the largest number of orders.The test cases are generated so that exactly one customer will have placed more orders than any other customer. 가장 많은 주문을 한 고객의 customer_number를 조회하는 문제이다. SolutionWITH step1 AS ( SELECT customer_number , COUNT(order_number) AS ord_cnt FROM Orders GROUP BY customer_number..
문제 Write a solution to find for each user, the join date and the number of orders they made as a buyer in 2019. 💡이 문제의 핵심은 JOIN과 LEFT JOIN의 특징을 정확히 알고, 적절한 조인 조건을 활용하는 것이다. SolutionSELECT u.user_id AS buyer_id , u.join_date , COUNT(CASE WHEN o.order_date LIKE '2019%' THEN o.order_id END) AS orders_in_2019 -- NULL은 COUNT 시 0FROM Users u LEFT JOIN Orders o ON u.user_id = o.buyer_idGROU..
문제 Write a solution to display the records with three or more rows with consecutive id's, and the number of people is greater than or equal to 100 for each. Return the result table ordered by visit_date in ascending order. 'id'가 연속적인 세 개 이상의 행을 찾되, 각 행의 'people'값이 100 이상인 경우에 해당하는 레코드를 출력하는 문제이다. 💡연속적이라는 단서를 보면 self-join을 통해 접근해 보자! Solution (1) ✔️ Stadium 테이블을 셀프 조인하여 세 개의 연속된 id 확인SELECT *F..
문제Write a solution to report the Capital gain/loss for each stock. The Capital gain/loss of a stock is the total gain or loss after buying and selling the stock one or many times. Return the result table in any order. 주식에 대한 각 'Sell' 작업은 이전 날에 해당하는 'Buy' 작업이 반드시 존재한다. 이 점을 참고하여, 하나의 주식을 한 번 또는 여러 번 사고판 후의 총 이익 또는 손실을 계산한다. SolutionSELECT stock_name , SUM(CASE WHEN operation = 'Buy' then -p..