如果我们有下一个构造,那么我会遇到“不能在没有条件的情况下使用”的问题,但是我想接收下一个流的综合浏览量,总和Enroll_Free_Lecture相同的人制作了pageview和Enroll_Free_Lecture应该在综合浏览量后完成Enroll_Free_Lecture并进行购买的人应该在Enroll_Free_Lecture之后。流程:1吨级综合浏览量第二级,综合浏览量第三级之后的Enroll_Free_Lecture,购买后Enroll_Free_Lecture:
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
`data` 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 `data`
as tb2, UNNEST(hits) as hitss) tb2 where tb2.date <= tb1.date and tb2.type = "pageview" ))
or (
tb1.eventAction = 'Purchase' and exists (
select 1
from `data` tb3, unnest (hits) hits
where hits.type = 'pageview'
and tb3.date <= tb1.date
) and exists (
select 1
from `data` tb3, unnest (hits) hitss
where hitss.eventInfo.eventCategory = 'Enroll_Free_Lecture'
and tb3.date <= tb1.date
)
)
答案 0 :(得分:0)
此错误是由您在WHERE
子句中的子查询中进行的比较引起的。如果您对以下比较进行评论,查询将运行。
with t as(select * from `deploy.ga`)
SELECT
tb1.*
FROM (
SELECT
date,
hits.type AS type,
hits.eventInfo.eventCategory AS eventCategory,
hits.eventInfo.eventAction AS eventAction,
hits.eventInfo.eventLabel AS person_email,
FROM
`deploy.ga`,
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
`deploy.ga` AS tb2,
UNNEST(hits) AS hitss) tb2
WHERE
tb2.type = "pageview" --AND
--tb2.date <= tb1.date
)
)
OR ( tb1.eventAction = 'Purchase'
AND EXISTS (
SELECT
1
FROM
`deploy.ga`tb3,
UNNEST (hits) hits
WHERE
hits.type = 'pageview'
--AND tb3.date <= tb1.date
)
AND EXISTS (
SELECT
1
FROM
`deploy.ga`tb3,
UNNEST (hits) hitss
WHERE
hitss.eventInfo.eventCategory = 'Enroll_Free_Lecture'
--AND tb3.date <= tb1.date
) )
为什么会这样? 我在这里看到两个错误:
select (select 1 ) t, (select count(1) from t)
或类似select (select 1 ) t where (select count(1) from t) = 1
,您会发现找不到表t
。JOIN
来比较两个不同表中的两个字段。如果您需要比较两个不同表中的两个字段,则必须以某种方式加入这些表。我希望对您有帮助