Feature 02 / 17
Ask with saved, parameterised queries
Save SQL and TugQL queries with named parameters, compose joins visually, preview the generated SQL, and run against the project’s sources in the browser.
Query workspaceAvailable
The problem
When the same question comes up for another customer or order, do you rewrite the SQL each time?
Useful queries end up in chat threads and text files with values pasted in by hand. Changing the customer means editing SQL, and nobody can tell which version produced last week’s answer.
A clearer workflow
Start from a saved query
Open a query from the project library, or write one in SQL or TugQL with named parameters such as a customer ID.
Compose and preview
Add tables and joins in Compose, check the declared relationships under Sources and Related, and inspect the SQL in Preview before anything runs. SQL a model wrote belongs in that editor too, so you can verify AI generated SQL before it runs.
Run with parameters
Enter the parameter values, run against a source you are allowed to use, and read the results beneath the editor.
Worked example
Rerun a saved query for a customer
Starting question
How do you run the saved Chinook invoice query for a customer of your choice?
Steps to follow
- Follow “Open the saved query” to open Chinook Customer Invoices. Customer ID 1 is prefilled under Parameters and stays editable.
- Choose Preview SQL to inspect the join and the customer filter before the query runs.
- Choose Run and read the invoice rows. Change the Customer ID and run again to ask the same question about another customer.
What you learn
One saved query answers the question for any customer you enter. In the pinned demo snapshot, Customer ID 1 returns seven invoices.
Open the saved queryWhat changes
A question becomes a named, reusable query that anyone on the project can rerun with new values.
The case of order 11045 · Act 1 · Find
In the demo story
Sarah runs a saved Northwind query with a customer parameter set to BOTTM, the Bottom-Dollar Markets ID, and sees order 11045 with no shipped date.
The guided demo of this story is being built. The worked example above runs in today’s demo project.
