我需要将以下代码放入 案子 声明。
select
count (*)
from db.tab1
lateral view explode(secondary.tertiary) exp as lv
where id IN ('6','1') and array_contains (lv.ci, "1");
我已经试过了
select
sum(
case
when id IN ('6','1')
and array_contains ((lateral view explode(secondary.tertiary)).ci, "1")
then 1
else 0
end)
from db.tab1;
但得到错误。
select
count(*),
sum(if(..., 1, 0))
from db.tab1
lateral view explode(secondary.tertiary) exp as lv
;
对于提供的SQL表 tab1
,实际逻辑是这样的。
secondary.tertiary
,别名为 lv
,结果是一个临时的结果集(表) tab2
; tab2
的字段回到 tab1
导致另一个中间表 tab3
; tab3
据此 where
条件是适用于。