Big query: LEFT OUTER JOIN cannot be used without a condition that is an equality of fields from both sides of the join

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-24 05:07:49

问题


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" )) 

回答1:


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
)


来源:https://stackoverflow.com/questions/61300443/big-query-left-outer-join-cannot-be-used-without-a-condition-that-is-an-equalit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!