Your question is Top-Performing Employee Each Month SQL. Start with the requirements and the three tables 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.
Paytm Operations needs a monthly leaderboard of employees based on completed sales processed through active Paytm channels. Write a PostgreSQL query that identifies every employee who ranked first each calendar month.
sale_status = 'completed' and an active channel.sale_amount by employee and month using the sale date.YYYY-MM, employee details, and the total sales amount, ordered chronologically and then by employee ID.| Column | Type | Description |
|---|---|---|
| employee_idPK | INTEGER | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee's full name |
| team | VARCHAR(100) | Operations team assigned to the employee |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INTEGER | Unique sale identifier |
| employee_id | INTEGER | Employee who handled the sale |
| channel_id | INTEGER | Paytm channel used for the sale |
| sale_date | DATE | Date on which the sale was recorded |
| sale_amount | NUMERIC(12,2) | Sale amount in rupees |
| sale_status | VARCHAR(20) | Processing status of the sale |
| Column | Type | Description |
|---|---|---|
| channel_idPK | INTEGER | Unique Paytm channel identifier |
| channel_name | VARCHAR(100) | Name of the Paytm sales channel |
| is_active | BOOLEAN | Whether the channel is active |