Converts a natural-language data requirement plus a table schema into a syntactically correct SQL query for a named database, with its assumptions stated up front.
Version 1 · 3 variables · 2 required
Fill in the values below — the customized prompt updates as you type. marks a required value.
Describe the result set in plain language: which rows, which aggregations, which filters, what order.
Tables with their columns, and key relationships if known. e.g. orders(id, customer_id, order_date, status)
e.g. PostgreSQL 15, MySQL 8.0, SQL Server 2022, BigQuery, SQLite Default: PostgreSQL 15
Fill in What you want the query to return, Schema to copy the customized prompt.
Copy the prompt and open a model site to paste it. PromptByte never sends your prompt anywhere — providers do not accept pre-filled prompts through a link.
**Assumptions**
- `order_items.order_id` joins to `orders.id`, and `products.category_id` joins to `categories.id`. These are inferred from the naming convention, since no foreign keys were listed.
- "Last 90 days" is measured against `orders.order_date` relative to today, inclusive of today.
- Revenue is `quantity * unit_price` summed over line items; there is no discount or tax column in the schema, so none is applied.
- Cancelled orders are excluded. If `status` uses different values than `'cancelled'`, adjust the filter.
- `COUNT(DISTINCT o.id)` is used rather than `COUNT(*)` because the join to `order_items` multiplies order rows by line item.
**Query**
```sql
SELECT c.name AS category,Showing all 1 public result on version 1.
**Assumptions**
- `order_items.order_id` joins to `orders.id`, and `products.category_id` joins to `categories.id`. These are inferred from the naming convention, since no foreign keys were listed.
- "Last 90 days" is measured against `orders.order_date` relative to today, inclusive of today.
- Revenue is `quantity * unit_price` summed over line items; there is no discount or tax column in the schema, so none is applied.
- Cancelled orders are excluded. If `status` uses different values than `'cancelled'`, adjust the filter.
- `COUNT(DISTINCT o.id)` is used rather than `COUNT(*)` because the join to `order_items` multiplies order rows by line item.
**Query**
```sql
SELECT c.name AS category,
COUNT(DISTINCT o.id) AS order_count,
SUM(oi.quantity * oi.unit_price) AS total_revenue
FROM orders AS o
JOIN order_items AS oi ON oi.order_id = o.id
JOIN products AS p ON p.id = oi.product_id
JOIN categories AS c ON c.id = p.category_id
WHERE o.order_date >= CURRENT_DATE - INTERVAL '90 days'
AND o.status <> 'cancelled'
GROUP BY c.id, c.name
HAVING COUNT(DISTINCT o.id) > 50
ORDER BY total_revenue DESC;
```
Grouping by `c.id` as well as `c.name` keeps the result correct if two categories share a display name. If `order_date` is a timestamp rather than a date, cast it (`o.order_date::date`) or the boundary day will be partially excluded.Contributor notes: Illustrative example — not an actual model run. Written to show the shape of a good answer so the prompt can be judged before you spend a call on it. Attribution: adapted from https://github.com/f/prompts.chat by f (Fatih Kadir Akın), licensed CC0-1.0. Source file: https://github.com/f/prompts.chat/blob/main/PROMPTS.md
Reports go to moderators and are never shown publicly.
```csv quarter,line,units_produced,defects,defect_rate_pct,shift_pattern Q1,Line A,14200,318,2.24,"Two shifts, weekdays" Q1,Line B,11850,402,3.39,"Two shifts, weekdays" Q1,Line C,9600,151,1.57,"One shift, weekdays" Q1,Line D,UNCLEAR,88,UNCLEAR,"One shift, weekends" Q2,Line A,15040,295,1.96,"Three shifts, weekdays" Q2,Line B,12310,377,3.06,"Two shifts, weekdays" Q2,Line C,9880,143,1.45,"One shift, weekdays" Q2,Line D,4120,96,2.33,"One shift, weekends" ``` **Notes** - **UNCLEAR cells:** row 5 (Q
Extracts a table from a screenshot or scanned page into a flat, copy-paste-ready CSV, unmerging cells, stripping units into their own columns and flagging anything unreadable instead of guessing.
# Checkout redesign A/B test — analysis plan and interpretation ## What the design supports Two independent groups, roughly 6,200 per arm, with a binary primary outcome (completed purchase) and a continuous secondary outcome (order value, right-skewed as order values almost always are). Randomisation at the session level with a 21-day run covering three full weekly cycles is sound. One caveat that limits every conclusion below: sessions, not users, were randomised, so a returning visitor could
Applies a senior statistician's workflow to your data: descriptive summary, justified test selection, models, effect sizes with confidence intervals, and a plain-language reading of what is practically significant.
## 1. Technical Audit & Business Context | Column | Smell | Business impact | |---|---|---| | `churn_date` | Populated only for churned accounts | This is the label in disguise. Any model that sees it will score ~perfectly in training and be useless in production. | | `mrr` | Right-skewed, a long tail of enterprise accounts | Mean imputation would drag small accounts upward and understate churn risk in the SMB segment, which is where outreach capacity actually sits. | | `signup_date` | Mixed `Y
Audits a raw dataset for data smells, ties each issue to its business impact, then proposes an imputation, encoding and scaling strategy with a leakage-safe pandas and scikit-learn pipeline.
**Recommended formula** — enter in Summary!B2 and fill down: =IFERROR(SUMIFS(Orders!$D$2:$D$5000, Orders!$B$2:$B$5000, $A2, Orders!$C$2:$C$5000, "Shipped", Orders!$A$2:$A$5000, ">="&DATE(2025,10,1), Orders!$A$2:$A$5000, "<="&DATE(2025,12,31)), 0) **How it works, step by step** 1. SUMIFS(sum_range, criteria_range1, criteria1, ...) adds values from Orders!D2:D5000 only for rows where every criteria pair matches. Unlike SUMIF it takes multiple conditions, so no helper column is needed. 2. Orders
Turns a described spreadsheet calculation into a working Excel formula plus a plain-language walkthrough of every function, operator and reference it uses.
Oldest first · one level of replies
Sign in to join the discussion. Share what you learned or made with this prompt.
No comments yet
Be the first to share how this prompt worked for you.