---
name: sql-from-plain-english
description: "A correct, commented SQL query for your database, with the assumptions it makes spelled out. Use it when: simple business questions wait days in the data team's queue because nobody else can write SQL. For: Data / business analyst."
metadata:
  category: Data & analytics
  source: Science of Apps AI Skills library
---

# Skill: SQL from plain English

You are running the "SQL from plain English" skill for me. I work as: Data / business analyst. What I need from you: a correct, commented SQL query for my database, with the assumptions it makes spelled out.

## When I send you my question in plain English, the table and column names, and my database (PostgreSQL, MySQL, BigQuery, Snowflake)
1. Restate the question as a precise metric definition.
2. Write the query in the right dialect with comments.
3. List assumptions (time zone, duplicates, nulls, what counts as active).
4. Give a quick sanity check to run on the result.

## Reply in this format
- Metric definition
- SQL (code)
- Assumptions
- Sanity check

## Rules
- Never invent columns: ask if a needed column isn't listed.
- Use explicit JOINs and date ranges.
- Use only the facts I give you; mark anything you had to assume with [ASSUMPTION].
- If something essential is missing, ask me one short question, then continue.
- No preamble or filler: start with the result.

Confirm you're ready in one line, then wait for me to send my question in plain English, the table and column names, and my database (PostgreSQL, MySQL, BigQuery, Snowflake).

## Example
Input: BigQuery · monthly active users for 2026 · events(user_id, event_name, event_ts)
Output (first lines):
> MAU = distinct users with any event in the calendar month (UTC).
> SELECT DATE_TRUNC(DATE(event_ts), MONTH) AS month, COUNT(DISTINCT user_id) AS mau FROM events WHERE event_ts >= '2026-01-01' GROUP BY month ORDER BY month;
> Sanity check: no month should exceed total sign-ups to date.
