코딩 테스트 연습/[프로그래머스][리트코드] MySQL

1068. Product Sales Analysis I

duswjd_data 2025. 8. 15. 08:50

문제

https://leetcode.com/problems/product-sales-analysis-i/description/


문제 설명

  • 두 테이블이 주어졌을 때,
    • Sales (컬럼 : sale_id, product_id, year, quantity, price
    • Product (컬럼 : product_id, product_name)
  •  각 판매 내역별로 다음 정보를 리턴 (product_name, year, price)

정답 코드

SELECT p.product_name, s.year, s.price
FROM sales AS s JOIN product AS p ON s.product_id = p.product_id