What would the SQL look like for a scenario presented by the interviewer?
Use the provided companies, payroll_runs, and payroll_items tables. Return company-level totals for completed payroll runs during the first quarter of 2025, including companies with no qualifying activity.
Output
- One row per company with
company_id, company_name, paid_workers, and total_gross_pay
- Include every company, using zero for companies without qualifying payroll items
- Sort by
total_gross_pay descending, then company_id ascending