We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 85ee08b commit d5abc63Copy full SHA for d5abc63
1 file changed
LeetCode SQL 50 Solution/180. Consecutive Numbers.sql
@@ -110,3 +110,24 @@ It then filters out rows where the current value is the same as both the previou
110
Final Output:
111
The final result is a list of distinct numbers that appear consecutively in the Logs table.
112
"""
113
+
114
115
+# Write your MySQL query statement below
116
117
+WITH
118
+ T AS (SELECT DISTINCT product_id FROM Products),
119
+ P AS (
120
+ SELECT product_id, new_price AS price
121
+ FROM Products
122
+ WHERE
123
+ (product_id, change_date) IN (
124
+ SELECT product_id, MAX(change_date) AS change_date
125
126
+ WHERE change_date <= '2019-08-16'
127
+ GROUP BY 1
128
+ )
129
130
+SELECT product_id, IFNULL(price, 10) AS price
131
+FROM
132
+ T
133
+ LEFT JOIN P USING (product_id);
0 commit comments