如何在Google BigQuery中按双周分组?

huangapple go评论43阅读模式
英文:

how to group by bi-weekly in google big query?

问题

我认为Google BigQuery提供了类似DATE_TRUNC的函数,但没有可以使用的双周参数。所以我想知道是否有任何方法可以实现这个功能。

英文:

I think google big query provide function like DATE_TRUNC, but there is no bi-week parameter can use. So I wonder if there any way we can implement this.

答案1

得分: 1

一种选择是使用generate_date_array函数,并传递2周的参数。

然后,您可以在查询中使用它作为内连接,以提取两周一次的时间段。希望这回答了您的问题。

SELECT GENERATE_DATE_ARRAY(current_date(), current_date() + 90, INTERVAL 2 WEEK) as bi_weekly_dates
英文:

one option is using generate_date_array function and passing the 2 weekly parameter.

You can then use this in your query as inner join to extract the bi-weekly slots. hope this answers your question.

SELECT GENERATE_DATE_ARRAY(current_date(), current_date() + 90, INTERVAL 2 WEEK) as bi_weekly_dates

huangapple
  • 本文由 发表于 2023年6月13日 07:27:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76460853.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定