【详述】关联子查询,主表不用别名则查询错误
【背景】
-
不起别名的sql,关联查询的结果是错误的。
select
#app_id
,(
select
max(#app_id@app_name
)
from
ods_dim_event_0preset_app_id td
where
#app_id
= td.#app_id
) as#app_id@app_name
from ods_fact_event_track
where 1=1
and#event
in (’#login’)
and#days
BETWEEN ‘2022-11-03’ and ‘2022-11-03’
and#app_id
= ‘264’
;
结果截图如下:这里的关联结果是错误的。
-
带别名的sql, 关联查询的结果是正确的
select
#app_id
,(
select
max(#app_id@app_name
)
from
ods_dim_event_0preset_app_id td
where
t.#app_id
= td.#app_id
) as#app_id@app_name
from ods_fact_event_track t
where 1=1
and#event
in (’#login’)
and#days
BETWEEN ‘2022-11-03’ and ‘2022-11-03’
and#app_id
= ‘264’
;
结果截图如下:这里的关联结果是正确的。
想问一下,如果不带别名的,是sr解析有问题吗?还是必须得加别名?
【业务影响】
【StarRocks版本】2.4.0
【集群规模】3fe + 5be