BigQuery Multi-Statement


BigQuery Multi-Statement Queries Example

 

main.sql

  -- Multi-Statement Queries Example

  -- Create a Temporary Table
  CREATE OR REPLACE TEMPORARY TABLE temp_table AS
  SELECT *
  FROM `your_project_id.your_dataset.your_source_table`
  WHERE date > '2023-01-01';

  -- Perform Aggregation
  SELECT
    DATE_TRUNC(DATE(date), MONTH) AS month,
    COUNT(*) AS total_records
  FROM temp_table
  GROUP BY month
  ORDER BY month;