如何在 BIGQUERY 中获取连续的日期范围
HOW TO GET SEQUENTIAL DATE RANGE IN BIQUERY
我有如下数据
enter image description here
我想要一个这样的table。
enter image description here
我怎样才能得到绘制的有效日期...?请帮助
您可以使用 BigQuery 中的 GENERATE_DATE_ARRAY 函数来实现您想要的。更具体地说:
WITH customers AS (
SELECT 123456 as customer_id,
DATE("2022-01-01") as start_date,
DATE("2022-01-03") as last_active
)
SELECT customer_id, start_date, last_active, active_
FROM customers, UNNEST(GENERATE_DATE_ARRAY(start_date, last_active, INTERVAL 1 DAY)) as active_
我有如下数据 enter image description here
我想要一个这样的table。 enter image description here
我怎样才能得到绘制的有效日期...?请帮助
您可以使用 BigQuery 中的 GENERATE_DATE_ARRAY 函数来实现您想要的。更具体地说:
WITH customers AS (
SELECT 123456 as customer_id,
DATE("2022-01-01") as start_date,
DATE("2022-01-03") as last_active
)
SELECT customer_id, start_date, last_active, active_
FROM customers, UNNEST(GENERATE_DATE_ARRAY(start_date, last_active, INTERVAL 1 DAY)) as active_