Write SQL Queries

Write SQL queries to analyze spans, logs, and metrics with joins and aggregations.

The SQL editor is available under Query Data > SQL in the left-hand navigation.

The editor provides syntax highlighting and formats your query on demand. Above the SQL input, describe what you want to query and click Generate to generate SQL. Review the generated query before running it.

SQL editor with a plain-language Generate input above the query and Execute, Format, Explain, and Optimize buttons below it

  • Execute (⌘ Enter on Mac, Ctrl Enter on Windows/Linux): runs the query against the current time window.

  • Format: reformats the query to standard SQL indentation and style without changing its semantics.

  • Explain: sends the query to an AI model and shows a plain-English breakdown of what each part does. This is useful when reading an unfamiliar template or debugging a complex join.

    SQL editor Explain panel showing AI-generated plain-English breakdown of query components

  • Optimize: asks AI to suggest an optimized query and explain the changes. Review the suggestion before applying it.

Supported Functions

Dash0 SQL supports a range of built-in functions for aggregation, string manipulation, date handling, array operations, math, logic, and JSON extraction.

For details, see Use Supported Functions.

Time Window

Dash0 SQL automatically applies the time range selected in the time picker to every query. You do not need to add a timestamp filter manually.

If you add an explicit filter on a timestamp column, it may conflict with the implicit time range.

See Troubleshoot SQL Queries for details.

Query Suggestions

When the editor is empty, a set of suggested queries appears below it, such as Errors in last 15m, Slow spans (>1s), Logs by service, and Recent errors by host.

SQL editor with empty input area showing suggested query options like Errors in last 15m and Slow spans

Click any suggestion to load it into the editor.

Keyboard Shortcuts

ActionShortcut
Run query⌘ Enter (Mac) / Ctrl Enter (Windows/Linux)
Open templates⌘ T
Open recent queries⌘ H
Open saved views⌘ S

Further Reading

Last updated: