case when 条件和where 条件的区别

比如select count(case when nvl(num,0) > 0 then 1) from tablename;
或者select count(1) from tablename where nvl(num,0) >0
这两个句子有区别吗?
最新回答
-她滥我情

2022-05-12 11:24:07

select * from 表 where 1=1 and (case when a=1 then a when 表.字段='asdfasdf' then b end)='值

ase when 变量a='provider' then 'cp.id' else {1} end
这就不是判断语句,这是赋值语句,where不能在后面
SQL code
?
1
2
3
4
SELECT CK.RESPERSON AS NAME
FROM CP_KPI_INFO_FY CK, CP_DIM_PROVIDER CP
WHERE CK.PROVIDERID = CP.ID
AND CP.ID = case when 变量a='provider' then 'cp.id' else '{1}' end;