You are a data analyst at a retail company working with two important tables: Product and Sales. Your task is to identify products with a very specific sales pattern.
The Product table contains information about each product:
| Column Name | Type |
|---|---|
| product_id | int (Primary Key) |
| product_name | varchar |
| unit_price | int |
The Sales table records every sale transaction:
| Column Name | Type |
|---|---|
| seller_id | int |
| product_id | int (Foreign Key) |
| buyer_id | int |
| sale_date | date |
| quantity | int |
| price | int |
Your Mission: Find all products that were sold exclusively during the first quarter of 2019 (January 1 to March 31, 2019). This means:
- โ The product must have at least one sale in Q1 2019
- โ The product must NOT have any sales outside Q1 2019 (before Jan 1, 2019 or after March 31, 2019)
Return the product_id and product_name of qualifying products in any order.
Input & Output
Visualization
Time & Space Complexity
Database can use indexes and optimized joins, typically O(n log n) with proper indexing
No additional space needed beyond database's internal processing
Constraints
- 1 โค Product table rows โค 1000
- 1 โค Sales table rows โค 104
- All product_id values in Sales table exist in Product table
- sale_date is in YYYY-MM-DD format
- Q1 2019 range is 2019-01-01 to 2019-03-31 (inclusive)