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
sales
+-----------+------------+----------+-------+
| order_id | order_date | is_prime | price |
+-----------+------------+----------+-------+
| 1001 | 2023-01-15 | 1 | 25.99 |
| 1002 | 2023-01-20 | 0 | 18.50 |
| 1003 | 2023-02-05 | 1 | 45.00 |
| 1004 | 2023-02-14 | 0 | 12.99 |
| 1005 | 2023-03-03 | 1 | 33.25 |
+-----------+------------+----------+-------+
##### Scenario
E-commerce analytics team needs monthly insights on Prime vs non-Prime sales and price-bucket performance over the last year.
##### Question
Write an SQL query that returns, for each of the past 12 months, total sales split into Prime and non-Prime customers. Using Python (pandas), compute for each month the percentage of sales contributed by each dynamically defined price_bucket (you decide reasonable bucket boundaries).
##### Hints
Use month truncation, GROUP BY, window functions; create bins with pd.cut; ensure percentages sum to 100% per month.
Quick Answer: 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.