Skip to content

Commit b70f581

Browse files
committed
Upload 119
1 parent ac21a09 commit b70f581

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To make the daily tasks of creating a new file and updating the index easier, th
2727

2828
## Contents
2929

30-
| Day | Title | Solution | Site | Difficulty | N2SELF |
30+
| Day | Title | Solution | Site | Difficulty | NB |
3131
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ----------- | ------------ | -------------------- |
3232
| 001 | [Histogram of Tweets](https://datalemur.com/questions/sql-histogram-tweets) | [Solution](solutions/001_histogram_of_tweets.md) | DataLemur | Easy | |
3333
| 002 | [User's Third Transaction](https://datalemur.com/questions/sql-third-transaction) | [Solution](solutions/002_users_third_transaction.md) | DataLemur | Medium | |
@@ -147,6 +147,7 @@ To make the daily tasks of creating a new file and updating the index easier, th
147147
| 116 | [Game Play Analysis IV](https://leetcode.com/problems/game-play-analysis-iv/description/) | [Solution](solutions/116_game_play_analysis_iv.md) | LeetCode | Medium | |
148148
| 117 | [Number of Unique Subjects Taught by Each Teacher](https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/description/) | [Solution](solutions/117_number_of_unique_subjects_taught_by_each_teacher.md) | LeetCode | Easy | |
149149
| 118 | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i/description/) | [Solution](solutions/118_user_activity_for_the_past_30_days_i.md) | LeetCode | Easy | `BETWEEN`, `DATE` w/ `INTERVAL` |
150+
| 119 | [Product Sales Analysis III](https://leetcode.com/problems/product-sales-analysis-iii/description/) | [Solution](solutions/119_product_sales_analysis_iii.md) | LeetCode | Medium | |
150151

151152
## Author(s)
152153

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SQL Everyday \#119
2+
3+
## Product Sales Analysis III
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Medium
7+
8+
## Problem
9+
10+
Write a solution to select the `product id`, `year`, `quantity`, and `price` for the `first year` of every product sold.
11+
12+
Return the result table in *any order*. [[Full Description](https://leetcode.com/problems/product-sales-analysis-iii/description/)]
13+
14+
## Submitted Solution
15+
16+
```sql
17+
-- Submitted Solution
18+
SELECT
19+
product_id
20+
,year as first_year
21+
,quantity
22+
,price
23+
FROM Sales
24+
WHERE (product_id, year) IN (
25+
SELECT
26+
product_id
27+
,MIN(year) as year
28+
FROM Sales
29+
GROUP BY product_id
30+
)
31+
;
32+
```
33+
34+
## Site Solution
35+
36+
```sql
37+
-- LeetCode Solution
38+
-- Site solution essentially the same.
39+
```
40+
41+
## Notes
42+
43+
TODO
44+
45+
Go to [Table of Contents](/README.md#contents)\
46+
Go to [Overview](/README.md)

0 commit comments

Comments
 (0)