You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SQL: -- Query W4: Determine the first and last sale date for the first 10 customers SELECT customer_id, MIN(sale_date) OVER (PARTITION BY customer_id) AS first_purchase, MAX(sale_date) OVER (PARTITION BY customer_id) AS last_purchase FROM sales QUALIFY ROW_NUMBER() OVER (ORDER BY customer_id) <= 10;
1005: error:
--> SQL:6:9
|
3 | -- Query W4: Determine the first and last sale date for the first 10 customers
4 | SELECT customer_id, MIN(sale_date) OVER (PARTITION BY customer_id) AS first_purchase, MAX(sale_date) OVER (PARTITION BY customer_id) AS last_purchase
5 | FROM sales
6 | QUALIFY ROW_NUMBER() OVER (ORDER BY customer_id) <= 10;
| ^^^^^^^^^^ unexpected `ROW_NUMBER`, expecting `GROUP`, `ORDER`, `IGNORE_RESULT`, `INTERSECT`, `VALUES`, `OFFSET`, `WHERE`, `WINDOW`, `FORMAT`, `WITH`, `LIMIT`, `HAVING`, `EXCEPT`, `SELECT`, `UNION`, `,`, `(`, or `;`
Expected:
The text was updated successfully, but these errors were encountered:
SQL: -- Query W7: Calculate the difference in net paid amount from the previous sale for the first 10 sales SELECT customer_id, sale_date, net_paid, LAG(net_paid, 1) OVER (PARTITION BY customer_id ORDER BY sale_date) - net_paid AS diff_from_prev_sale FROM sales QUALIFY ROW_NUMBER() OVER (ORDER BY customer_id, sale_date) <= 10;
1005: error:
--> SQL:6:9
|
3 | -- Query W7: Calculate the difference in net paid amount from the previous sale for the first 10 sales
4 | SELECT customer_id, sale_date, net_paid, LAG(net_paid, 1) OVER (PARTITION BY customer_id ORDER BY sale_date) - net_paid AS diff_from_prev_sale
5 | FROM sales
6 | QUALIFY ROW_NUMBER() OVER (ORDER BY customer_id, sale_date) <= 10;
| ^^^^^^^^^^ unexpected `ROW_NUMBER`, expecting `GROUP`, `ORDER`, `IGNORE_RESULT`, `INTERSECT`, `VALUES`, `OFFSET`, `WHERE`, `WINDOW`, `FORMAT`, `WITH`, `LIMIT`, `HAVING`, `EXCEPT`, `SELECT`, `UNION`, `,`, `(`, or `;`
Summary
Table setup:
https://github.com/BohuTANG/wizard/blob/main/checksb/sql/selects/bend/setup.sql
Error:
Expected:
The text was updated successfully, but these errors were encountered: