Derive Key Business Metrics Using SQL or Python
Company: Amazon
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: Medium
Interview Round: Technical Screen
Orders
+----------+-------------+------------+---------+------------------+
| order_id | customer_id | order_date | amount | product_category |
+----------+-------------+------------+---------+------------------+
| 1 | 101 | 2023-01-05 | 120.00 | Electronics |
| 2 | 102 | 2023-01-06 | 55.00 | Home |
| 3 | 101 | 2023-01-15 | 220.00 | Electronics |
| 4 | 103 | 2023-02-01 | 80.00 | Books |
| 5 | 102 | 2023-02-03 | 35.00 | Home |
+----------+-------------+------------+---------+------------------+
Customers
+-------------+---------------+
| customer_id | customer_name |
+-------------+---------------+
| 101 | Alice |
| 102 | Bob |
| 103 | Carol |
| 104 | Dan |
| 105 | Eve |
+-------------+---------------+
##### Scenario
You are given two tables from an e-commerce platform and need to derive business metrics for the analytics team.
##### Question
For each calendar month, return the three product_category values with the highest total sales amount. Break ties by larger total sales, then alphabetically. 2. For every customer, produce a result showing order_id, order_date, amount, and that customer’s running cumulative_amount ordered by order_date. 3. Classify each order as 'High' (amount >
200), 'Medium' (amount BETWEEN 100 AND
200) or 'Low' (else). Return the count of orders in each class.
##### Hints
Expect to JOIN, aggregate with SUM, use CASE WHEN, and apply window functions such as ROW_NUMBER or RANK; avoid unnecessary sub-queries where possible.
Quick Answer: This question evaluates data manipulation and analytical querying skills, including joins, aggregations, conditional classification, and running-window computations in the Data Manipulation (SQL/Python) domain.