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

**URL:** <https://community.omni.co/t/querying-a-results-set-save-as-query-view/359>\
**Category:** Workbooks\
**Created:** [July 14, 2025, 10:50pm UTC](https://community.omni.co/t/querying-a-results-set-save-as-query-view/359 "2025-07-14T22:50:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![conner](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.omni.co/conner/32/11_2.png) [@conner](https://community.omni.co/u/conner)\
**Post date:** [July 14, 2025, 10:50pm UTC](https://community.omni.co/t/querying-a-results-set-save-as-query-view/359/1 "2025-07-14T22:50:40Z")

</div>

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](https://docs.omni.co/docs/querying-and-sql/saved-views#create) is built for exactly that 😃 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

[![](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/f618f1cde5ba4452a4b214c6885ce849b93c93a4.jpeg "Save as query view") ](https://vimeo.com/1101366706)

# Using “Save as query view” (with the UI)

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

 ![Model > Save as query view](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/b33d74cacebb6d87e6503550d212ca97ee36ccb1.jpeg)

Give your query a name:

 ![Name your query](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/3ca8e7be45de3a88a9e76f1e3b85840ebda875f5.png)

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.”

 ![Edit your query view in the UI](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/ae94d0f9a9ade29d9d5790016821ac07265dba10.png)

# Using “Save as query view” (with SQL)

Sometimes, you just want to write SQL instead of using Omni’s UI to build the query. This is especially useful for building more complex queries, such as window functions.

For this, simply open a [SQL tab](https://docs.omni.co/docs/querying-and-sql/sql#sql-tabs) in your workbook, and write SQL just like how you would against the database. When you’re happy with your results, you can click “Save as query view” in the top right corner of the tab page.

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/41deff23b17cdaf80bc2ad53d374493c061b677b.png)

# Using the Query View

From here, you can simply click “Use in query” from the View tab, to query directly on top of your Saved View

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/7be928054973759eb35f46ba652d887cd5cd5f51.png)

You’ll also 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.

 ![Underlying SQL](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/fe79cbfde8bc6697ff15d5aa3433417744d79c01.png)

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.

 ![Screenshot 2025-07-14 at 3.39.38 PM](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/3b880d10bf5a3cbd494fb5e7cd730f3382f98028.png)

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:

 ![Adding query view to your original Topic](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/cd2f32b2982ad22ee3afcd481782df16f727fb0b.png)

# Query view use cases

> [@Automating Complex Assignments in Omni with CSV Uploads and Saved Query Views: A Step-by-Step Guide](https://community.omni.co/t/automating-complex-assignments-in-omni-with-csv-uploads-and-saved-query-views-a-step-by-step-guide/267):
>
> In this tutorial, we’ll explore how to leverage input tables to combine a results set and a lookup table with complex criteria, all within Omni. Specifically, we’ll demonstrate how to dynamically assign campaign managers based on category and total sales price criteria. Pre-requisites: Set up csv write back to your data warehouse ([docs here](https://docs.omni.co/docs/connections/upload-csvs)) User must have one of the following roles: restricted queriers, queriers, OR connection admin Video Guide Written Guide Step 1: Preparing Your Data Beg…

> [@Rank Pivots by a Measure (Top N)](https://community.omni.co/t/rank-pivots-by-a-measure-top-n/225):
>
> If you have a chart where you’d like to show the Top 3, 5, 15 or any number of values based on how they rank over a measure - this tutorial will show you how in a few short steps. Turn this: Into this: play_button Text based walkthrough with codeplay_button Video Walkthrough

> [@Binning & Regrouping Aggregates / Creating a "histogram"](https://community.omni.co/t/binning-regrouping-aggregates-creating-a-histogram/152):
>
> A common workflow is taking a table, aggregating it, and then analyzing patterns in the aggregation. For example: take an orders table, aggregate it to count of orders per user, and then understand % of users per count of lifetime orders. Often, this results in a histogram-type chart that plots the number of values that fall into a given range. In Omni, this binning & regrouping workflow is simple with our [Saved Views](https://docs.omni.co/docs/querying-and-sql/saved-views) feature: Aggregate your table (i.e. aggregat…
