From 0094ac1f491848050694c73fc10608be5c9eed86 Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Tue, 1 Jul 2025 18:53:04 +0300 Subject: [PATCH] task: #1068 --- README.md | 1 + .../easy/1068. Product Sales Analysis I.sql | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 leetcode/easy/1068. Product Sales Analysis I.sql diff --git a/README.md b/README.md index e175fde..5f8756b 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Have a good contributing! - [610. Triangle Judgement](./leetcode/easy/610.%20Triangle%20Judgement.sql) - [619. Biggest Single Number](./leetcode/easy/619.%20Biggest%20Single%20Number.sql) - [620. Not Boring Movies](./leetcode/easy/620.%20Not%20Boring%20Movies.sql) + - [1068. Product Sales Analysis I](./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql) 2. [Medium](./leetcode/medium/) - [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql) - [184. Department Highest Salary](./leetcode/medium/184.%20Department%20Highest%20Salary.sql) diff --git a/leetcode/easy/1068. Product Sales Analysis I.sql b/leetcode/easy/1068. Product Sales Analysis I.sql new file mode 100644 index 0000000..f143168 --- /dev/null +++ b/leetcode/easy/1068. Product Sales Analysis I.sql @@ -0,0 +1,46 @@ +/* +Question 1068. Product Sales Analysis I +Link: https://leetcode.com/problems/product-sales-analysis-i/description/ + +Table: Sales + ++-------------+-------+ +| Column Name | Type | ++-------------+-------+ +| sale_id | int | +| product_id | int | +| year | int | +| quantity | int | +| price | int | ++-------------+-------+ +(sale_id, year) is the primary key (combination of columns with unique values) of this table. +product_id is a foreign key (reference column) to Product table. +Each row of this table shows a sale on the product product_id in a certain year. +Note that the price is per unit. + + +Table: Product + ++--------------+---------+ +| Column Name | Type | ++--------------+---------+ +| product_id | int | +| product_name | varchar | ++--------------+---------+ +product_id is the primary key (column with unique values) of this table. +Each row of this table indicates the product name of each 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. +*/ + +SELECT + p.product_name, + s.year, + s.price +FROM Sales AS s +LEFT JOIN + Product AS p + ON s.product_id = p.product_id