首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >大查询:如果没有连接两侧的字段相等的条件,则不能使用左外部连接

大查询:如果没有连接两侧的字段相等的条件,则不能使用左外部连接
EN

Stack Overflow用户
提问于 2020-04-19 14:31:54
回答 1查看 101关注 0票数 0

请帮帮忙。我创建了下一个查询,但生成了问题,但我不知道如何修复它enter image description here

代码语言:javascript
复制
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" )) 
EN

回答 1

Stack Overflow用户

发布于 2020-04-20 09:30:55

下面是针对BigQuery标准SQL的说明

代码语言:javascript
复制
#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
)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61300443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档