Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 프로젝트
- 웹 스크랩핑
- 미세먼지
- 스파르타 코딩
- MySQL
- 내일배움
- 스파르타
- SQL
- TiL
- 내일배움카드
- 내일배움캠프
- wil
- 텍스트 분석
- 스파르타코딩
- 티스토리챌린지
- 실전 데이터 분석 프로젝트
- 파이썬 머신러닝 완벽 가이드
- 회귀분석
- harkerrank
- hackerrank
- 파이썬 머신러닝 완벽가이드
- 중회귀모형
- 프로그래머스
- 어쩌다 마케팅
- 파이썬 철저입문
- R
- 오블완
- 파이썬 철저 입문
- 파이썬
- Cluster
Archives
- Today
- Total
OkBublewrap
Supercloud Customer 본문
Supercloud Customer
문제
1. 모든 product_category에서 최소 한 개의 제품을 구매한 고객
select customer_id
from (
select cc.customer_id, count(product_category) as cnt
from customer_contracts cc
left join products p on cc.product_id = p.product_id
group by cc.customer_id, p.product_category
) sub1
group by customer_id
having count(*) = (select count(distinct product_category) from products)
풀이
1️⃣ sub1: customer_contracts, products left join
2️⃣ sub1: customer_id, product_category별로 숫자세기
3️⃣ group by: customer_id 그룹
4️⃣ having: products 테이블에서 고유한 product_category 수 가져오기
5️⃣ 해당 product_category가 다 있는 customer_id 출력
'개발 > SQL' 카테고리의 다른 글
Well Paid Employees (0) | 2025.03.10 |
---|---|
Average Review Ratings (0) | 2025.03.10 |
Signup Activation Rate (0) | 2025.03.09 |
Cities With Completed Trades (0) | 2025.03.09 |
Duplicate Job Listings (0) | 2025.03.09 |