Working wih sub queries

Top  Previous  Next

 

Note: This chapter describes working with Sub-queries used in criteria expressions to limit result dataset (usually in the WHERE and HAVING clauses). To find out how to work with sub-queries used as datasources for the main query (ie. in the FROM and WITH clauses), please refer to the Derived tables chapter.

 

You may add a sub-query as part of the expression or condition in the Columns Pane while editing text in a cell. To add a sub-query, right click at the text position for a new sub-query and select the Insert Sub-query item from context popup menu or type the "= (Select)" or "In (Select)" statement directly into the Criteria column. Please note that the statement should be enclosed in parentheses.

 

screens - adding sub-query

Adding a sub-query

 

To build a newly added sub-query visually, confirm editing by pressing the Enter key. The corresponding tab is created above the Query Building Area. Selecting a subquery from the tab control will open a new tab where you can visually the subquery in the same way as the main query. If the cell contains more than one sub-query, a drop-down list will appear to select the one you want.

 

You can get back to the main query and switch to any sub-query or derived table either by using these tabs or by using the Query Structure Tree.

 

 

screens - sub-query added

Getting access to a sub-query