coding

Top customers per country (SQL)

Prompt
Tables: orders(id, customer_id, total, created_at) and customers(id, name, country). Write a PostgreSQL query that returns the top 3 customers by total spend in calendar year 2025 for each country, with columns country, name, spend, rank. Ties should share a rank.

Answers will appear here after the first test run.