Prompt Details
Model
Chat - (gpt-5.6)
Token size
507
Example input
[DATABASE SCHEMA]: orders(order_id, customer_id, order_date, amount) customers(customer_id, customer_name)
[ANALYSIS QUESTION]: Find the top 10 customers by total spending during 2026.
[SQL DIALECT]: PostgreSQL
[BUSINESS CONTEXT]: The business wants to identify its highest-value customers for customer retention and loyalty programs.
Example output
SQL QUERY
SELECT
customer_id,
SUM(amount) AS total_spent
FROM orders
WHERE order_date >= '2026-01-01'
GROUP BY customer_id
ORDER BY total_spent DESC;
QUERY EXPLANATION
The query filters orders from January 1, 2026 onward, groups them by customer, calculates total spending for each customer, and sorts customers from highest to lowest spending.
EXPECTED RESULT
A result set containing:
- customer_id
- total_spent
Each row represents one customer and their total spending during the selected period.
ANALYSIS
This query helps identify the highest-value customers based on total purchase amount.
ASSUMPTIONS & EDGE CASES
- amount should contain numeric values.
- NULL amounts may need to be handled depending on the database.
- Duplicate order records could affect totals.
OPTIMIZATION
An index on order_date and customer_id may improve performance on large datasets.
VALIDATION CHECKLIST
1. Confirm order_date uses the expected date format.
2. Check for duplicate orders.
3. Verify that amount is stored as a numeric field.
FINAL ANSWER
SELECT
customer_id,
SUM(amount) AS total_spent
FROM orders
WHERE order_date >= '2026-01-01'
GROUP BY customer_id
ORDER BY total_spent DESC;
Purpose: Identify customers with the highest spending during the selected period.
Get this prompt + 9 more with Select$14 your first month, then $19/mo$14 first month, then $19/mo
View SelectBy purchasing this prompt, you agree to our terms of service
GPT-5.6
Turn natural-language data questions into practical SQL queries and actionable analysis. Provide your database schema, SQL dialect, analysis question, and optional business context. Get a ready-to-use query, explanation, expected results, insights, edge cases, and optimization suggestions. The prompt avoids inventing tables or columns and is useful for data analysis, reporting, dashboards, SQL practice, and technical interviews.
...more
Added over 1 month ago
