The Query Builder has support for multiple Unioned statements.
An example of a Union query is:
Select * from SAMPLE.SALES_DETAILS_2015
Select * from SAMPLE.SALES_DETAILS_2016
Select * from SAMPLE.SALES_DETAILS_2017
Select * from SAMPLE.SALES_DETAILS_2018
This combines the results of multiple sets of data.
Creating a Union Query
Once you have built the first SQL statement in your query, you can add another statement with:
- Union > Add statement
- going to the Union tab and clicking on Add New Statement
Each Statement is Built Individually
With the Query Builder you build each statement individually:
- use Next / Prev to move through the different statements in your query
- the message in the status-bar at the bottom will show you which statement you are dealing with
- the SQL in the bottom panel will either be the SQL for the statement you are dealing with, or for the entire Unioned query. Clicking Full SQL will switch between these.
- the Union tab will allow you to view and manage the different statements in your query
Running the Query
- if Full SQL is selected, Run will run the full query
- if Full SQL is not selected, Run will just run the statement you are building.
When you Save the query, or copy it to the clipboard / SQL window, this will be the full query.