Is there any way I can emulate the behavior of FILTER (http://modern-sql.com/feature/filter) in standard SQL BigQuery?
What I would need to do is:
SELECT
MAX(date) FILTER (WHERE event_happend = 1)
OVER (
PARTITION BY user_id
ORDER BY date ASC
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
)
FROM
...
In essence I need to work out the most recent date a certain event occurred prior to the date of the current row.
Column event_happened takes values 0 and 1 and I need the most recent date on which the event occurred (event_happened = 1) prior to the date of the current row.