Goal
Write one correct, readable SQL query that answers the question below on the schema provided.
Inputs
- Database: [MySQL, PostgreSQL, SQL Server, SQLite, BigQuery]
- Question: [e.g. top 10 customers by revenue in the last 90 days]
- Schema: [paste table names with columns and types]
- Relationships: [e.g. orders.customer_id links to customers.id]
- Notes on data: [e.g. cancelled orders have status 'cancelled']
Output format
- The query, formatted with one clause per line and keywords in capitals.
- Explanation: a numbered list that walks through each clause in the order the database runs it.
- Sample output: a small table showing the column names and two or three made-up rows labelled as illustrative.
- Assumptions: any decision made where the question was unclear.
- Performance note: indexes that would help if the tables are large.
Check before answering
- Every table and column used exists in the pasted schema.
- The query uses syntax valid for the stated database, including date functions.
- Joins use the stated relationships and the right join type; a LEFT JOIN is used where missing rows must still appear.
- Aggregates have a matching GROUP BY.
- Date ranges are inclusive or exclusive on purpose, and the choice is stated.
- NULL values and duplicates are handled.
- No SELECT star in the final query.
- The query only reads data. Never write UPDATE, DELETE or DROP unless explicitly asked.






