Table of Contents

Search

  1. About the Data Vault SQL Reference
  2. Introduction to SQL Reference for Informatica Data Vault
  3. Date and Time Arithmetic
  4. WHERE Clauses
  5. UNION Operator
  6. Parameterized Query
  7. Functions

Data Vault SQL Reference

Data Vault SQL Reference

UNION

UNION

The UNION operator combines the result sets of multiple SELECT statements but does not include duplicate rows in the final result set. The final result set contains only distinct rows from all the SELECT statements.

Syntax

The UNION operator has the following syntax:
SELECT column1 [, columnN ] FROM table1 [, tableN ] [WHERE clause] UNION SELECT column1 [, columnN ] FROM table1 [, tableN ] [WHERE clause]
Examples
The following UNION query selects the same number of columns from different tables:
SELECT location_id, department_name, FROM departments UNION SELECT location_id, warehouse_name FROM warehouses;
The following UNION query selects all columns from multiple tables that have the same number of columns of the same datatype:
SELECT * FROM departments UNION SELECT * FROM warehouses UNION SELECT * FROM offices;
The following UNION query includes an ORDER BY clause:
SELECT City FROM Customers UNION SELECT City FROM Suppliers ORDER BY City;

0 COMMENTS

We’d like to hear from you!