Last updated
Calculate the bonus earned by each salesman in each quarter based on sales targets and car make bonus rules.
Calculate the bonus earned by each salesman in each quarter based on sales targets and car make bonus rules.
Your dataset contains two sales performance tables: 1. A Sales table with car make, type, style, sale value, purchase date, and salesman reference 2. A Salesman table with salesman IDs and names Analyze quarter-wise bonus earned by each salesman based on sales performance, car make bonus, and quarterly target achievement.
| Column | Type | Key / Notes |
|---|---|---|
| sale_id | INT | PK |
| make | VARCHAR(50) | |
| type | VARCHAR(50) | |
| style | VARCHAR(50) | |
| cost_$ | DECIMAL(10,2) | |
| purchased_date | DATE | |
| salesman_id | INT | FK |
| Column | Type | Key / Notes |
|---|---|---|
| salesman_id | INT | PK |
| name | VARCHAR(50) |
Salesman — 4 rows
| salesman_id | name |
|---|---|
| 101 | John Doe |
| 102 | Jane Smith |
| 103 | Robert Brown |
| 104 | Emily Davis |
Sales — 9 rows
| sale_id | make | type | style | cost_$ | purchased_date | salesman_id |
|---|---|---|---|---|---|---|
| 1 | Honda | Sedan | Accord | 2800 | 2023-05-15 | 104 |
| 2 | BMW | SUV | X5 | 6000 | 2023-02-20 | 102 |
| 3 | Audi | Sedan | A4 | 45000 | 2022-11-13 | 104 |
| 4 | Ford | Truck | F-150 | 40000 | 2023-07-24 | 103 |
| 5 | Nissan | Hatchback | Civic | 2200 | 2023-03-30 | 103 |
| 6 | Mercedes | Sedan | C-Class | 45000 | 2022-09-17 | 101 |
| 7 | Toyota | SUV | GLC | 52000 | 2023-01-05 | 102 |
| 8 | Audi | SUV | Q5 | 55000 | 2022-08-21 | 101 |
| 9 | BMW | Truck | Frontier | 28000 | 2023-04-18 | 104 |
Car Make Bonus — 7 rules
| Car Make | Bonus per Sale |
|---|---|
| Honda | 200 |
| Ford | 350 |
| Audi | 400 |
| Nissan | 120 |
| Toyota | 270 |
| BMW | 600 |
| Mercedes | 590 |
Quarterly Sales Target — 4 rules
| Quarter | Months | Sales Target |
|---|---|---|
| Q1 | January, February, March | 100000 |
| Q2 | April, May, June | 60000 |
| Q3 | July, August, September | 1000000 |
| Q4 | October, November, December | 1000000 |
Quarter-wise Salesman Bonus Analysis: What is the total bonus received by each salesman in each quarter? Bonus rule: Bonus = 10% of total sales + car make bonus. If a salesman does not meet the sales target for a quarter, they receive only the car make bonus for that quarter. The final result table should have name, q1, q2, q3, and q4 columns.
Your output should look like this (partial example):
| name | q1 | q2 | q3 | q4 |
|---|---|---|---|---|
| Emily Davis | 0 | 800 | 0 | 400 |
| Jane Smith | 870 | 0 | 0 | 0 |
| John Doe | 0 | 0 | 990 | 0 |