Querying a results set ("Save as query view")

Ever wanted to “query a query”? In other words, take some results and use that as the basis for another query?

Omni’s “Save as query view” feature is built for exactly that :smiley: Once you save your results as a query view, you can interact with it just like any other table you access in Omni — you can query it, join it, add it to Topics, etc.

If you’re familiar with SQL, it’s similar to writing some SQL, stuffing it into a CTE, and then writing more SQL on top of it. Except in Omni, you can do it all with your cursor, and re-use the base query elsewhere!

A quick video walkthrough

Using “Save as query view”

Once you’ve created the results set you want, navigate to “Model” in the top nav > “Save as query view.”

Give your query a name:

You’ll enter this “Query view” UI, where you can adjust the query view as you like. Once you’re ready, hit “Use in query.”

From here, you’ll see your new query in “All views & fields”. It’s just like any other table coming from your database; you can query it, join it, add it to Topics, etc. You can even open the SQL tab to ensure that it captured the logic you intended to.

You’ll often want to join it to the data you were working with already. Omni’s smart and will automatically create a join to the base table of the query it was built from.

So you can head back to your original query tab, open the join module from the original table, and then add in your new “query view” to the Topic:

Query view use cases