medium
Generate Complex SQL Query
Write a SQL query to join multiple tables and aggregate data.
📝 Conteúdo do Prompt
Write a PostgreSQL query that lists the top 5 customers by total purchase amount in the last month. Assume tables named 'customers' (id, name) and 'orders' (id, customer_id, amount, date). Join the tables, filter for the last month, group by customer, and order by the total sum descending.