Write Custom SQL
Explore your data warehouse using the SQL Runner. This feature allows you to preview SQL queries and subsequently create workbooks and datasets directly from SQL.
This article will show you how to use the SQL Runner to create a new workbook or dataset. Custom SQL-based workbook data elements can also be created from within an existing workbook. Both flows use the SQL Runner.
Summary of Content
- To use this feature, you must be a Creator or be assigned a custom account type with permission to write custom SQL.
- To run SQL against a connection, you must have Can Use access your data at the connection level. Learn more
- The SQL Runner will only appear if you have connection level access to at least one connection in your organization.
Create a Workbook or Dataset from SQL
- Click the Create New button in the left side navigation panel to open the Create New / Explore Data menu.
- Select Write SQL.
- Select your connection from the dropdown menu.
- The data tree on the left side of the page will allow you to explore your data.
You may choose to click on any table to preview its data.
- To write SQL, begin typing keywords into the text box in the top half of the screen. Sigma will automatically provide a list of autocomplete options to guide you.
- To run your SQL query, click the blue Run button.
Keyboard shortcuts: CTRL-Enter on a PC or CMD-Enter on a Mac.
- To explore your query in a workbook, click the Explore button the top right corner of the page.
To create a dataset, click the dropdown icon next to Explore. Then click Create Dataset.
Format your SQL
Use the format SQL icon button to quickly format long blocks of SQL text.
When you are using the SQL runner, you will have access to a history of the queries you've recently run against your current connection. To access this history, click the ‘History’ tab in the left hand panel.
View Multiple Tables
When writing your query, you can still use the left side menu to explore data tables. You can switch between the Table Preview and SQL results, letting you preview what columns you may want to use when joining data tables.
|Mac Shortcut||PC Shortcut||Command|
|CMD + Enter||CTRL + Enter||Submit query for execution|
|CTRL + Space||CTRL + Space||Open autocomplete|
|CMD + /||CTRL + /||Toggle commenting on or off for the highlighted line|
|CMD + Left||Go to the start of the line|
|Shift + Tab||Shift + Tab||Indent less|
|Shift + CTRL + K||Shift + CTRL + K||Delete current line|
|CMD + L||CTRL + L||Select line|
|CMD + CTRL + Up||Shift + CTRL + Up||Shift line up|
|CMD + CTRL + Down||Shift + CTRL + Down||Shift line down|
|CMD + J||CTRL + J||Join Lines|
|Shift + CMD + D||Shift + CTRL + D||Duplicate line|
|CMD + K CMD + K||CTRL + K CTRL + K||Delete the portion of the line to the right of the cursor|
|CMD + K CMD + delete||CTRL + K CTRL + Backspace||Delete the portion of the line to the left of the cursor|
|CMD + K CMD + U||CTRL + K CTRL + U||Upcase at cursor|
|CMD + K CMD + L||CTRL + K CTRL + U||Downcase at cursor|