Analyze Monthly Prime vs Non-Prime Sales and Price Buckets
Company: Amazon
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Onsite
Overview: This question evaluates data manipulation and analytics competencies, including SQL time-based aggregation and segmentation as well as practical use of Python (pandas) for dynamic price-bucketing and percentage calculations.
Monthly Prime vs Non-Prime Sales
Tables
sales(order_id INTEGER, order_date DATE, is_prime INTEGER, price DECIMAL(10,2))
Hints
- Use generate_series to enumerate months between 2023-01-01 and 2023-03-01.
- Use date_trunc('month', order_date) to group orders by month.
Monthly Price Bucket Percentages
Tables
sales(order_id INTEGER, order_date DATE, is_prime INTEGER, price DECIMAL(10,2))
Hints
- Define price buckets with a CASE expression based on price.
- First aggregate sales per month and price_bucket, then compute monthly totals.