2025/04/28 3

3-Topping Pizzas: McKinsey SQL Interview Question

문제 풀이 링크: https://datalemur.com/questions/pizzas-topping-cost McKinsey SQL Interview Question | DataLemurMcKinsey SQL Interview Question: Write a query to calculate the cost of 3-topping pizzas.datalemur.com 🍕 3-토핑 피자 조합 비용 계산 문제 요약목적: 서로 다른 3개 토핑으로 만들 수 있는 모든 피자 조합에 대해 총 재료 비용을 계산하고 출력조건:토핑은 반복 없이 서로 달라야 함 (예: 'Pepperoni,Pepperoni,Onion' ❌)토핑 이름은 알파벳 순서대로 나열해야 함 (예: 'Chicken,Onions,Sausage' ✅)..

SQL 2025.04.28

Histogram of Users and Purchases: Walmart SQL Interview Question

문제 풀이 링크: https://datalemur.com/questions/histogram-users-purchases Walmart SQL Interview Question | DataLemurWalmart SQL Interview Question: Write a query to retrieve the the users along with the number of products they bought.datalemur.com🧢 Walmart 사용자 거래 내역 문제 요약목적: 사용자별 가장 최근 거래일 기준으로 거래일, user_id, 구매한 상품 개수를 조회하기조건: 가장 최근 거래일만 대상으로 집계, 결과는 거래일 기준 오름차순으로 정렬1. 내 풀이먼저 날짜별(user_id, transaction..

SQL 2025.04.28

User Shopping Sprees: Amazon SQL Interview Question

문제풀이 링크: https://datalemur.com/questions/amazon-shopping-spree👒 아마존 쇼핑 스프리 고객 식별 문제 요약목적: 쇼핑 스프리를 경험한 고객(user_id)을 식별조건: 3일 이상 연속으로 구매한 이력이 있어야 하며, 최종 출력은 user_id 기준 오름차순 정렬쇼핑 스프리 정의:3일 이상 연속해서 매일 구매한 경우를 쇼핑 스프리로 인정 셀프 조인(Self Join) 사용:같은 테이블을 2번 조인하여 거래 날짜가 +1일, +2일 차이 나는 레코드 연결이때, user_id가 같은 경우만 조인DATE() 함수로 날짜만 비교:transaction_date에 시간이 포함되기 때문에 DATE()로 시간을 제거하고 날짜만 뽑아 정확한 하루 단위 비교 SELECT T1..

SQL 2025.04.28