Skip to main content

SQL Query Explainer

See a best-effort outline of one SELECT query's top-level clauses. SQL stays in your browser and is never executed; nested or dialect-specific syntax may not be recognized.

Supports one SELECT statement, optionally preceded by WITH CTEs. Only top-level clauses are outlined; dialect-specific syntax may not be recognized. SQL stays in your browser and is never executed. Maximum: 50,000 UTF-16 code units. Press Ctrl+Enter or Command+Enter to explain.

Query structure

Found 8 top-level sections. This is a structural outline, not SQL validation or query results.

  1. WITH / CTE

    Defines named intermediate queries used by the SELECT. CTE contents are kept together in this outline.

    WITH recent_orders AS (
      SELECT user_id, total
      FROM orders
      WHERE created_at >= '2025-01-01'
    )
  2. SELECT

    Lists the expressions or columns in the result. It does not show returned data.

    SELECT users.name, COUNT(recent_orders.total) AS order_count
  3. FROM

    Names the data sources; joins and their conditions stay in this section.

    FROM users
    LEFT JOIN recent_orders ON recent_orders.user_id = users.id
  4. WHERE

    Filters source rows before grouping and aggregation.

    WHERE users.active = TRUE
  5. GROUP BY

    Groups source rows for aggregate expressions.

    GROUP BY users.name
  6. HAVING

    Filters groups after aggregation.

    HAVING COUNT(recent_orders.total) > 0
  7. ORDER BY

    Specifies the order of the query results.

    ORDER BY order_count DESC
  8. LIMIT

    Requests a maximum number of rows where supported.

    LIMIT 20;

Was this tool helpful?