SQL query to answer: If occurs in timepoint A, does occur in time period B-C?

前端 未结 2 1361
感动是毒
感动是毒 2021-01-25 04:05

I\'m querying a large data set to figure out if a bunch of campaign events (i.e. event 1,2,..) during different timepoints gives a result in user activity (active, inactive) dur

2条回答
  •  情歌与酒
    2021-01-25 04:31

    You seem to be quite there. A range partition is the right way to go. BigQuery only supports integers in such frame, so we need to convert the date to a number; since you have dates with no time component, UNIX_DATE() comes to mind:

    WINDOW 3d_later AS (
        PARTITION BY user 
        ORDER BY UNIX_DATE(cm.date) 
        RANGE BETWEEN 1 FOLLOWING AND 3 FOLLOWING
    )
    

提交回复
热议问题