Duplicating records to fill gap between dates in Google BigQuery

前端 未结 2 410
刺人心
刺人心 2021-01-14 08:08

So I\'ve found similar resources that address how to do this in SQL, like this: Duplicating records to fill gap between dates

I understand that BigQuery may not be t

2条回答
  •  长情又很酷
    2021-01-14 08:51

    I need to generate a table that has all the dates within a given range, but I'm having a hard time understanding if this can be done. Any ideas?

    SELECT DATE(DATE_ADD(TIMESTAMP("2016-08-01"), pos - 1, "DAY")) AS DAY
    FROM (
         SELECT ROW_NUMBER() OVER() AS pos, *
         FROM (FLATTEN((
         SELECT SPLIT(RPAD('', 1 + DATEDIFF(TIMESTAMP("2016-08-07"), TIMESTAMP("2016-08-01")), '.'),'') AS h
         FROM (SELECT NULL)),h
    )))
    

提交回复
热议问题