如何在BigQuery中使用table_range函数连接表?

时间:2016-03-10 23:24:56

标签: sql google-bigquery

SELECT
  *
FROM TABLE_DATE_RANGE(dataset.tableA, DATE_ADD(CURRENT_TIMESTAMP(), -1,'day'), DATE_ADD(CURRENT_TIMESTAMP(), -1, 'day')) AS org_table
JOIN (
  SELECT
    name,
    id
  FROM
    dataset.tableB) AS new_table
ON
   org_table.id = new_table.id

BigQuery不允许我为TABLE_DATE_RANGE()提供别名,如何进行此连接?

1 个答案:

答案 0 :(得分:4)

SELECT
  *
FROM (
  SELECT * 
  FROM TABLE_DATE_RANGE(dataset.tableA, DATE_ADD(CURRENT_TIMESTAMP(), -1,'day'), DATE_ADD(CURRENT_TIMESTAMP(), -1, 'day'))
) AS org_table
JOIN (
  SELECT
    name,
    id
  FROM
    dataset.tableB) AS new_table
ON
   org_table.id = new_table.id