Write a query to identify the top three highest-paying payroll runs for each business category in a given month at Gusto.
Use May 2024 for the sample data and include completed payroll runs only. Exclude runs whose business has no category.
business_category, payroll_run_id, business_id, payroll_date, total_gross_pay, and payroll_rank.payroll_run_id.business_category, then payroll_rank.| Column | Type | Description |
|---|---|---|
| business_idPK | INT | Unique identifier for a business |
| business_name | VARCHAR(150) | Business name |
| business_category | VARCHAR(80) | Business category used to partition payroll runs |
| Column | Type | Description |
|---|---|---|
| payroll_run_idPK | INT | Unique identifier for a payroll run |
| business_id | INT | Business associated with the payroll run |
| payroll_date | DATE | Date of the payroll run |
| total_gross_pay | NUMERIC(12,2) | Total gross payroll amount |
| status | VARCHAR(20) | Payroll run status |