Your question is Rank Fastest-Growing Seller Revenue. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given seller order data from a marketplace. Write a PostgreSQL query that identifies the sellers whose revenue is growing fastest month over month, based on the largest percentage increase in the latest month compared with the previous month. Return one row per seller with their latest month, previous month revenue, growth amount, and growth rate, then rank sellers from highest to lowest growth rate.
Use window functions to compare each seller’s monthly revenue to the prior month. Exclude sellers who do not have revenue in both months needed for the comparison.
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Primary key for each order |
| seller_id | INT | Unique seller identifier |
| seller_name | VARCHAR(255) | Seller display name |
| order_date | DATE | Date the order was completed |
| order_revenue | DECIMAL(10,2) | Revenue from the order |