Growth ๐ŸŒณ/Practice ๐Ÿ’ป

[Leet Code] 1068. Product Sales Analysis I

์ธ” 2023. 10. 7. 23:48

๐Ÿ“ข ๋ณธ ํฌ์ŠคํŒ…์— ํ™œ์šฉ๋˜๋Š” ๊ธฐ๋ณธ ๋ฌธ์ œ ๋ฐ ์ž๋ฃŒ ์ถœ์ฒ˜๋Š”

       ๋ฆฌํŠธ์ฝ”๋“œ 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;

 

'Growth ๐ŸŒณ > Practice ๐Ÿ’ป' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Leet code] 1978. Employees Whose Manager Left the Company  (0) 2023.10.11
[Leet code] 1084. Sales Analysis III  (0) 2023.10.10
[Leet code] 1075. Project Employees I  (1) 2023.10.06
[Leet code] 1934. Confirmation Rate  (1) 2023.10.05
[Leet code] 1393. Capital Gain/Loss  (1) 2023.10.04