[Leet Code] 1068. Product Sales Analysis I
๐ข ๋ณธ ํฌ์คํ ์ ํ์ฉ๋๋ ๊ธฐ๋ณธ ๋ฌธ์ ๋ฐ ์๋ฃ ์ถ์ฒ๋
๋ฆฌํธ์ฝ๋ Problems, https://leetcode.com/problemset/all/์์ ๋ฐํ๋๋ค.
โ๋ฌธ์
https://leetcode.com/problems/product-sales-analysis-i/description/
LeetCode - The World's Leading Online Programming Learning Platform
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
Table : Sales
Table : Product
Write a solution to report the product_name, year, and price for each sale_id in the Sales table.
Return the resulting table in any order.
…
โ ํ์ด
๋ฌธ์ ์๊ตฌ์ฌํญ
Sales_id๋ณ๋ก ์ํ๋ช , ์ฐ๋, ๊ฐ๊ฒฉ์ ์ถ๋ ฅํด์ผ ํ๋ค.
Sales ๋ product์ id, ํ๋งค๋, ๊ฐ๋น ๊ฐ๊ฒฉ ์ ๋ณด๋ฅผ ํน์ ์ฐ๋์ ๋ฐ๋ผ ์ ๊ณตํ๊ณ
Product๋ product_id, product_name์ ์ ๊ณตํ๋ค.
์ํ๋ณ ์ํ๋ช , ์ฐ๋, ๊ฐ๋น ๊ฐ๊ฒฉ์ ๊ฐ sale_id๋ณ๋ก ์ถ๋ ฅํด์ผ ๋๊ธฐ ๋๋ฌธ์
Sales ํ ์ด๋ธ ๊ธฐ์ค LEFT JOINํด์ Sales ์ด๋ ฅ์ ์ถ๋ ฅํ๋ค.
SELECT product_name, year, price
FROM Sales T1
LEFT JOIN Product T2
ON T1.product_id = T2.product_id;