Skip to content

Commit 85ee08b

Browse files
1164. Product Price at a Given Date
Co-Authored-By: Antim-IWP <203163676+Antim-IWP@users.noreply.github.com>
1 parent 277cb6a commit 85ee08b

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
1164. Product Price at a Given Date
3+
4+
Table: Products
5+
6+
+---------------+---------+
7+
| Column Name | Type |
8+
+---------------+---------+
9+
| product_id | int |
10+
| new_price | int |
11+
| change_date | date |
12+
+---------------+---------+
13+
(product_id, change_date) is the primary key (combination of columns with unique values) of this table.
14+
Each row of this table indicates that the price of some product was changed to a new price at some date.
15+
16+
17+
Write a solution to find the prices of all products on 2019-08-16. Assume the price of all products before any change is 10.
18+
19+
Return the result table in any order.
20+
21+
The result format is in the following example.
22+
23+
24+
25+
Example 1:
26+
27+
Input:
28+
Products table:
29+
+------------+-----------+-------------+
30+
| product_id | new_price | change_date |
31+
+------------+-----------+-------------+
32+
| 1 | 20 | 2019-08-14 |
33+
| 2 | 50 | 2019-08-14 |
34+
| 1 | 30 | 2019-08-15 |
35+
| 1 | 35 | 2019-08-16 |
36+
| 2 | 65 | 2019-08-17 |
37+
| 3 | 20 | 2019-08-18 |
38+
+------------+-----------+-------------+
39+
Output:
40+
+------------+-------+
41+
| product_id | price |
42+
+------------+-------+
43+
| 2 | 50 |
44+
| 1 | 35 |
45+
| 3 | 10 |
46+
+------------+-------+

LeetCode SQL 50 Solution/180. Consecutive Numbers.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ It then filters out rows where the current value is the same as both the previou
109109
110110
Final Output:
111111
The final result is a list of distinct numbers that appear consecutively in the Logs table.
112-
"""
112+
"""

0 commit comments

Comments
 (0)