SQL Practice Logo

SQLPractice Online

Level 3 - IntermediateDebugging Questions

Debugging: Window Alias in WHERE

Fix this query that errors on alias reference. SELECT id, customer_id, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date DESC) AS rn FROM orders WHERE rn = 1;

Schema Context

orders(id, customer_id, order_date)