File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -110,3 +110,24 @@ It then filters out rows where the current value is the same as both the previou
110110Final Output:
111111The final result is a list of distinct numbers that appear consecutively in the Logs table.
112112" " "
113+
114+
115+ # Write your MySQL query statement below
116+ # Write your MySQL query statement below
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+ FROM Products
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);
You can’t perform that action at this time.
0 commit comments