【发布时间】:2019-03-04 02:26:00
【问题描述】:
我只是想通过使用 exists 子句来限制数据,但它似乎无法识别 EXISTS 子句中的别名(就像在 Oracle 中那样)
我正在使用这个 sql
select count(1) from
(select distinct
case when qp_cguid is null then ssid else qp_cguid end cguid,
case when qp_vid is null then vid else qp_vid end as visit_id,
TIMESTAMP_MILLIS(creation_date_time) visit_date_time
from `zone1.table1` as t1
where _partitiontime in ( timestamp( '2019-01-01') )
and case when qp_vid is null then vid else qp_vid end is not null
and case when qp_cguid is null then ssid else qp_cguid end is not null
and exists
(
select 1 from `zone2.ga_temp` AS ga
where ga.cguid = t1.cguid
and (t1.visit_date_time between TIMESTAMP_ADD(ga.min_hit_time_utc, INTERVAL -10 SECOND) and TIMESTAMP_ADD(ga.max_hit_time_utc, INTERVAL 10 SECOND))
)
)
这给了我这个错误
“在 t1 中找不到名称 cguid”
关于如何解决这个问题的任何想法?
【问题讨论】:
标签: google-bigquery alias exists