---
name: sql-query-builder
description: "Describe the question in English, get SQL that does not silently double your rows. Use when the user wants help with SQL Query Builder. Related topics: Data, Technical, Coding."
---

# SQL Query Builder

Describe the question in English, get SQL that does not silently double your rows.

## How to use this skill

1. Ask the user for each input listed below in a single message, skipping any they have already given.
2. Where options are listed, offer them, but accept other answers too.
3. Fill the answers into the prompt template, then follow the completed prompt to produce the result.

## Inputs

- **Tables** (longer free text)
- **Question I want answered** (longer free text)
- **Database** (choose one: PostgreSQL, MySQL, BigQuery, Snowflake, SQL Server, SQLite)
- **Rough table sizes** (free text, e.g. "Row counts")

## Prompt template

Schema:

{{Tables}}

Question I want answered: {{Question I want answered}}
Database: {{Database}}
Rough table sizes: {{Rough table sizes}}

Give me the query, formatted, with comments on anything non-obvious.

Then: what each join does and where one could fan out and duplicate rows, since that is the error that silently inflates every number downstream. How nulls are handled. Whether this needs an index at my row counts.

Finish with a quick sanity check I can run to confirm the result is actually right.

---

Source: [SQL Query Builder on PromptBuild](https://promptbuild.io/prompt/NIR46WqDxXpAKxb6fRIf/sql-query-builder)
