SQLDesk

Queries and parameters

A query is SQL against one data source, saved, with an owner and, if you like, a schedule.

Running one

Execute runs it and stores the result. Selecting part of the SQL runs only the selection, which is the fastest way to work on a piece of a long statement.

The result is kept. Everyone opening a dashboard sees the stored result and its age rather than causing a fresh run, which is why dashboards open quickly.

Parameters

Write {{ name }} in the SQL and a control appears. Press the settings icon beside it to choose what kind it is:

Text
Free text. Refused on publicly shared dashboards, because text spliced into SQL is how a shared link becomes a way to run arbitrary statements.
Number
A number, safely.
Dropdown
A fixed list you type. Safe to share, and usually what a text parameter should have been.
Query-based dropdown
The list comes from another query, so it stays current.
Date / date range
With relative options — last 7 days, this month — that move with the calendar.

Parameter values travel in the URL (?p_region=North), so a filtered view can be linked and bookmarked.

Scheduling

A query can refresh on a schedule so its dashboards are ready before anyone opens them. Pick the longest interval that is still useful — a five-minute refresh on a query nobody reads before Monday is paid for by your warehouse every five minutes.

Scheduled runs use the parameter defaults; there is nobody there to choose.

Permissions

You can query any data source your groups give full access to; view-only access shows results but runs no new SQL. With Enable experimental multiple owners support on (Settings → General), a query can be shared for editing with specific people; without that, others can run and view it but not change it.

History

History, in the query's ⋮ menu, lists every version of it: when it changed, who changed it, and what they changed. Pick one to see the diff — either what that version changed, or how it compares with the query as it is now, which is the question to ask before restoring.

Restore writes a new version that says what the old one said. Nothing is rewritten and nothing is deleted, so the version you restored stays in the list. A restore puts back the SQL, the name, the description, the parameters, the schedule and the tags — not the data source, and not whether the query is published or archived: those have their own controls, and an undo that quietly moved a query to another warehouse would be a surprise.

Anyone who can read the query can read its history; the restore is offered only to somebody who could have made the same edit by hand.

Snippets and formatting

Snippets are reusable fragments — Settings → Query Snippets — inserted by typing their trigger. Format Query tidies SQL for the dialects that support it.