SQL
All Top 50 SQL Interview Questions#38
Find Product Price as of a Target Date in SQL
MediumFlipkartInterview Question #38
Asked at FlipkartGiven a `products` table (product_id, new_price, change_date), find the price of all distinct products on '2026-08-16'. Assume all products had an initial base price of 10 before any price change.
Input Table: products
5 rows preview| product_id | new_price | change_date |
|---|---|---|
| 1 | 20 | 2026-08-14 |
| 2 | 50 | 2026-08-14 |
| 1 | 30 | 2026-08-15 |
| 1 | 35 | 2026-08-18 |
| 3 | 30 | 2026-08-17 |
Expected Output Structure3 rows
| product_id | price |
|---|---|
| 1 | 30 |
| 2 | 50 |
| 3 | 10 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.