BigQuery : How do you create a table from a query result in BigQuery ?

Google Big Query @ Freshers.in

You can create a new table in BigQuery from the results of a query by using the ” CREATE TABLE ” statement. The basic syntax for creating a table from a query result is as follows:

Syntax
CREATE TABLE [new_table_name] AS
SELECT [column1], [column2], ...
FROM [existing_table_name]
WHERE [condition];

For example, suppose you have a table named “freshers_table”  with columns column1, column2, and column3, and you want to create a new table with only the rows where column1 is equal to “A”. You can use the following query to create a new table named my_new_table from the result:

CREATE TABLE my_new_table AS
SELECT column2, column3
FROM freshers_table
WHERE column1 = 'A';

This will create a new table named my_new_table that contains only the rows from freshers_table where column1 is equal to “A”, and includes only the column2 and column3 columns.

It’s also important to note that the CREATE TABLE statement will create a new table based on the current state of the data at the time the statement is executed. If the data in the original table changes, the new table will not be updated automatically. To update the new table, you’ll need to run the CREATE TABLE statement again.

BigQuery import urls to refer

Author: user

Leave a Reply