有人可以解释一下为什么会这样:
select val1, val2,
count(case when table2.someID in (1, 2, 3, 48967, 123456) then table2.someId end) as val3
from table1
join table2 on table1.someId = table2.someId
where blabla
group by val1, val2
order by val1
但这里的查询:
select val1, val2,
count(case when table2.someID in (Select someId from table567) then table2.someId end) as val3
from table1
join table2 on table1.someId = table2.someId
where blabla
group by val1, val2
order by val1
给出错误:
无法对包含聚合或子查询的表达式执行聚合函数。
(someId
在PK中table2
)