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
- 스파르타
- 웹 스크랩핑
- 오블완
- 회귀분석
- 스파르타코딩
- 티스토리챌린지
- R
- SQL
- 미세먼지
- 중회귀모형
- 내일배움캠프
- 내일배움카드
- 실전 데이터 분석 프로젝트
- 파이썬 철저입문
- 파이썬
- 텍스트 분석
- MySQL
- 프로그래머스
- 내일배움
- 어쩌다 마케팅
- 파이썬 철저 입문
- TiL
- Cluster
- hackerrank
- 파이썬 머신러닝 완벽 가이드
- 스파르타 코딩
- 프로젝트
- wil
- harkerrank
- 파이썬 머신러닝 완벽가이드
Archives
- Today
- Total
OkBublewrap
1070. Product Sales Analysis III 본문
1070. Product Sales Analysis III
문제
- 모든 제품이 판매된 첫 번째 연도를 기준으로
product_id
,year
,quantity
,price
- any order
입력 테이블
Sales
sale_id
product_id
year
quantity
price
Product
product_id
product_name
풀이
1. product_id별 최소 연도 구하기
product_id
별 year
최소연도 구하기
select product_id, min(year) as first_year
from Sales
group by product_id
2. 조건절 사용
product_id
와 year
와 맞는 데이터 가져오기
select product_id, year as first_year, quantity, price
from Sales
where (product_id, year) in (
select product_id, min(year) as first_year
from Sales
group by product_id)
'개발 > SQL' 카테고리의 다른 글
1164. Product Price at a Given Date (0) | 2025.01.24 |
---|---|
180. Consecutive Numbers (0) | 2025.01.22 |
1934. Confirmation Rate (0) | 2025.01.21 |
1280. Students and Examinations (0) | 2025.01.20 |
기계당 평균 처리 시간 (0) | 2025.01.17 |