I am using Google Bigquery to compare date field on two different rows, like this:
I would like evaluate the rows that have the same ID and are more than 30 minutes beetween them, but I am not able to compare two different rows beetwen them, and I coul even omit one of them, and count only the equal customerid rows that have more than 30 minutes beetween them…
Thank you very much.
Advertisement
Answer
If you want to know if the customer accessed last more than 30 minutes before, use lag()
:
select t.*, (process_time_A > timestamp_add(lag(process_time_A) over (partition by customerId order by process_time_A), interval 30 minute) ) as is_more_than_30_minutes from t