Text to SQL: generate JOINs from plain English

Ask a question that spans multiple tables. Chion profiles every foreign key and relationship, generates the correct JOIN type, and validates conditions against your schema — before anything touches your database.

How Chion handles JOINs

Foreign keys and relationships profiled automatically.

During schema profiling, Chion catalogs every foreign key, unique constraint, and cross-table relationship. When your question references data from multiple tables, the pipeline selects the appropriate JOIN type based on the relationship and your intent.

The SQL contract enforces that every JOIN condition references real columns with compatible types. Mis-aliased or non-existent columns are caught by the two-layer validator (L1 read-only check, L2 runtime lint) and repaired automatically.

Examples: English → JOIN queries

Multi-table questions with validated ON conditions.

"Which products haven't been ordered in 90 days?"LEFT JOIN + IS NULL
SELECT p.product_name
FROM products p
LEFT JOIN orders o
  ON o.product_id = p.id
  AND o.order_date >= CURRENT_DATE - INTERVAL '90 days'
WHERE o.id IS NULL;
"Revenue per employee by department"Multi-table JOIN + ratio
SELECT d.department_name,
  SUM(r.revenue) / COUNT(DISTINCT e.id) AS rev_per_employee
FROM departments d
JOIN employees e ON e.department_id = d.id
JOIN revenue r ON r.department_id = d.id
GROUP BY d.department_name;
"Customers with orders but no payments"LEFT JOIN anti-pattern
SELECT c.customer_name
FROM customers c
JOIN orders o ON o.customer_id = c.id
LEFT JOIN payments p ON p.order_id = o.id
WHERE p.id IS NULL;
"Average order value by category and region"4-table JOIN
SELECT c.category_name, r.region,
  AVG(o.total) AS avg_order_value
FROM orders o
JOIN products p ON p.id = o.product_id
JOIN categories c ON c.id = p.category_id
JOIN customers cu ON cu.id = o.customer_id
JOIN regions r ON r.id = cu.region_id
GROUP BY c.category_name, r.region;
"Customers who bought in both Q1 and Q2"Self-join
SELECT a.customer_id
FROM orders a
JOIN orders b ON a.customer_id = b.customer_id
WHERE a.order_date BETWEEN '2025-01-01' AND '2025-03-31'
  AND b.order_date BETWEEN '2025-04-01' AND '2025-06-30';

JOIN FAQ

Try multi-table JOINs in plain English

Connect your PostgreSQL database and ask a question that spans multiple tables.