Table of Contents

Sub-Queries: Re-Use Queries in Other Queries

you are here (click to zoom) - discover the stack

You can re-use a Query inside another one, just like calling functions in your code.

This feature uses the QueryRun DataSource.

Example in VisualQuery

As you'll see in the image below, the QueryRun DataSource actually runs another query and re-uses it.

Walkthrough Video

Watch this video for a walkthrough to learn how to use it yourself.

Checklist to Use Sub-Queries

Best Practices

In many cases you'll have sub-queries which expect parameters. You could assume that they come from the URL like [QueryString:Id] but when re-using the query it's better to pass it through the parameters because it will give the caller more control over what parameters are used. In the above example, it's better to do this:

  1. The sub-query would use [Params:Id] to use the Params-ID
  2. The caller would then set Params:Id=[QueryString:Id] or anything else as needed


  • Introduced in 2sxc 10.24