Metabase - SQL editor SQL editor

Get more detailed results with SQL queries

For the data analysts, data scientists, data engineers, developers and other data specialists. The SQL editor lets you get down with native queries when it isn’t your first rodeo.

SQL queries with a few extra bells and whistles

The flexibility and control you want from writing native queries, made a little cushier.

Worry-free upgrades, backups, and more - Upgrades

SQL parameters

Create SQL templates by adding variables to your SQL queries. You can add filter widgets to modify the SQL query before it’s run for different results.

Worry-free upgrades, backups, and more - Upgrades

SQL snippets

Save, reuse, and share bits of SQL code to avoid rewriting the same thing. You can also organize snippets in folders and customize permissions (available on Pro and Enterprise.)

Worry-free upgrades, backups, and more - Upgrades

Dashboard filter

Set up a SQL question to filter a dashboard, as long as it has one or more variable.

Worry-free upgrades, backups, and more - Upgrades

Autocomplete

Write queries faster with autocomplete for keywords, tables, column names, and more.

Worry-free upgrades, backups, and more - Upgrades

Data reference

Check the data reference in the sidebar for a quick refresher on the exact names of tables and columns as you’re writing a query.

Worry-free upgrades, backups, and more - Upgrades

Start from a model

Use models as a jumping off point for asking more complex questions with a SQL query, with the benefit of vetted column definitions.

More about asking questions in Metabase

How to ask a question with SQL

1
Click New > SQL Query at the top of Metabase. Note that you won’t see this option if you don’t have native query access. An admin can configure this for you if you need it.
2
Write your SQL query (if you’re using the SQL editor, you know what to do, don’t let us get in your way).
3
Click the ▶️ button to view results below.
4
To turn results into a chart, click Visualization and pick the best fit for your data. You can click around and see a preview below your query.
5
Save, add to a collection, a dashboard, share, live long and prosper, etc.