case when 条件和where 条件的区别 20
比如selectcount(casewhennvl(num,0)>0then1)fromtablename;或者selectcount(1)fromtablenamewh...
比如select count(case when nvl(num,0) > 0 then 1) from tablename;
或者select count(1) from tablename where nvl(num,0) >0
这两个句子有区别吗? 展开
或者select count(1) from tablename where nvl(num,0) >0
这两个句子有区别吗? 展开
1个回答
展开全部
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;
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;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询