下面一段SQL,如果不加where str1 = '1' 执行速度很快,仅需5秒,但是加入where查询之后,无法产生结果,总体数据量仅有20万,各位大拿给看看是什么原因。SQL如下:selectcount(distinct str1)from(select
a1.str0
,a1.str4
,case when a2.str3=1 then '1' else '0' end a...
显示全部下面一段SQL,如果不加where str1 = '1' 执行速度很快,仅需5秒,但是加入where查询之后,无法产生结果,总体数据量仅有20万,各位大拿给看看是什么原因。
SQL如下:
select
count(distinct str1)
from
(
select
a1.str0
,a1.str4
,case when a2.str3=1 then '1' else '0' end as str1
from table1 a1
left join table2 a2
on a1.str0=a2.str0
)
where str1 = '1'
收起