Reputation: 15
Help, please. I created the next query but gen issue and I don`t understand how to fix it enter image description here
SELECT
tb1.*
FROM
(SELECT
tb1.date,
clientId,
REGEXP_EXTRACT (hits.pagePath,"^([^\?]+)\?") as page_url,
hits.type as type,
hits.eventInfo.eventCategory AS eventCategory,
hits.eventInfo.eventAction AS eventAction,
hits.eventInfo.eventLabel AS person_email,
FROM
`table` AS tb1, UNNEST (hits) AS hits) as tb1
where tb1.type = "pageview" or (tb1.eventCategory = "Enroll_Free_lecture" and
exists (select tb2.date, tb2.type from(select date, hitss.type as type From `table`
as tb2, UNNEST(hits) as hitss) tb2 where tb2.date <= tb1.date and tb2.type = "pageview" ))
Upvotes: 0
Views: 164
Reputation: 173200
Below is for BigQuery Standard SQL
#standardSQL
SELECT * EXCEPT(flag)
FROM (
SELECT
tb1.date,
clientId,
REGEXP_EXTRACT (hits.pagePath,"^([^\?]+)\?") AS page_url,
hits.type AS type,
hits.eventInfo.eventCategory AS eventCategory,
hits.eventInfo.eventAction AS eventAction,
hits.eventInfo.eventLabel AS person_email,
COUNTIF(type = "pageview") OVER(ORDER BY `date`) AS flag
FROM `table` AS tb1,
UNNEST (hits) AS hits
)
WHERE type = "pageview" OR (
eventCategory = "Enroll_Free_lecture"
AND flag > 0
)
Upvotes: 1