GROUP BY + ORDER BY + LIMIT
AP renewal season. I need the top 10 vendors by 2025 YTD spend — show `vendor_name` and `total_spend`, sorted highest to lowest, limit 10. Only posted entries. Include all account types.
Each hint you reveal reduces the XP you can earn. Try the query first.
JOIN `fact_transactions` to `dim_vendors`, filter `posted = 1` and year 2025.
GROUP BY vendor_name (or vendor_id), SUM(amount) AS total_spend, ORDER BY total_spend DESC, LIMIT 10.
Remember the trailing-space Stripe — if your LOWER(TRIM(...)) collapsed them, that's fine; if not, you'll see both. Either output is acceptable.