google-big-queryHow do I use the UNION clause in Google BigQuery?
The UNION clause allows you to combine the results of two or more SELECT queries into a single result set. To use the UNION clause in Google BigQuery, you must specify the same number of columns in each SELECT query. The data type of the columns must also be the same.
For example, the following query combines the results of two SELECT queries:
SELECT name, age
FROM `dataset.table1`
UNION
SELECT name, age
FROM `dataset.table2`
The output of this query would be a single result set containing the combined results of both SELECT queries.
The parts of the example code are as follows:
SELECT name, age- This specifies the columns to be returned in the result set.FROMdataset.table1`` - This specifies the source table for the first SELECT query.UNION- This specifies that the results of the two SELECT queries should be combined.FROMdataset.table2`` - This specifies the source table for the second SELECT query.
For more information on using the UNION clause in Google BigQuery, see the official documentation.
More of Google Big Query
- ¿Cuáles son las ventajas y desventajas de usar Google BigQuery?
- How do I use Google Big Query with Zoom?
- How can I use Google BigQuery to retrieve data from a specific year?
- How do I use the YEAR function in Google BigQuery?
- How can I export data from Google Big Query to an XLSX file?
- How can I use Google BigQuery to wait for a query to complete?
- How do I use wildcards in Google BigQuery?
- How do I use a Google BigQuery URL?
- How can I use Google BigQuery to access Wikipedia data?
- How can I use the CASE WHEN statement in Google Big Query?
See more codes...