Interview Questions/SQL/Product Sales Analysis I

Product Sales Analysis I

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Product Sales Analysis I

You have two tables: Sales and Product. Each row in Sales records a sale of a product in a given year at a given price. Write a SQL query to report the product_name, year, and price for each sale. Return the result in any order.

Examples

Example 1

Nokia (product_id=100) was sold in 2008 and 2009 for 5000. Apple (product_id=200) was sold in 2011 for 9000. Samsung has no sales.

Approach hint

Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

query.sql