The Average Selling Price interview question is a SQL task involving two tables: Prices (containing product_id, start_date, end_date, and price) and UnitsSold (containing product_id, purchase_date, and units). You need to calculate the average selling price for each product. The average price is Total Revenue / Total Units. This Average Selling Price coding problem is about joining tables on non-exact matches (date ranges).
Companies like Amazon, Apple, and Oracle use this to test a candidate's ability to join tables based on a range (purchase_date BETWEEN start_date AND end_date). It also evaluates your handling of NULL values (using IFNULL or COALESCE) and your ability to perform weighted average calculations in SQL.
This follows the Database interview pattern of "Join-Group-Aggregate."
Product 1: Price 25 (Jan 16-30). Sales: 10 units on Jan 5, 20 units on Jan 20.
Practice "Range Joins" in SQL. Joining data based on a date being within a specific window is a very common real-world scenario in e-commerce and finance analytics.