Your question is Top Vendors by Spend. Start with the requirements and the two 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.
Zoox's procurement team wants to identify the vendors with the highest total charges over the most recent two-year period. Write a PostgreSQL query using the current date as the end of the period.
CURRENT_DATE - INTERVAL '2 years' through CURRENT_DATE.vendor_id as a deterministic tie-breaker.vendors.| Column | Type | Description |
|---|---|---|
| vendor_idPK | INTEGER | Unique vendor identifier |
| vendor_name | VARCHAR(150) | Vendor's business name |
| Column | Type | Description |
|---|---|---|
| charge_idPK | INTEGER | Unique charge identifier |
| vendor_id | INTEGER | Vendor associated with the charge |
| charge_date | DATE | Date the charge was recorded |
| amount | NUMERIC(12,2) | Dollar amount of the charge |