select
case
when fild='1' then count(fild)
end 第一个 ,
case
when fild='2' then count(fild)
end 第二个,
case
when fild='3' then count(fild)
end 第三个,
c.name
from a group by name
------解决方案--------------------
decode(fild,null,0,fild)
------解决方案--------------------
nvl()
------解决方案--------------------
nvl(count(fild),0)
------解决方案--------------------
nvl(count(fild),0)
NVL( string1, replace_with) 功能:如果string1为NULL,则NVL函数返回replace_with的值,否则返回string1的值。
------解决方案--------------------
NVL(表达式1,表达式2)
如果表达式1是NULL,则返回表达式2
如果表达式1非NULL,则返回表达式1
表达式1和表达式2可以是数字,字符串,日期格式,1和2的数据类型必须一致
NVL2(expr1,expr2,expr3)
如果expr1为空,则返回expr3,否则返回expr2
------解决方案--------------------
nvl
------解决方案--------------------
select case when sx_tj is not null then 1 when sx_tj is null then 0 end s from s_entity_attribute
这样?
------解决方案--------------------
- SQL code
selectcasewhen fild='1' then NVL(count(fild),0)end 第一个 ,casewhen fild='2' then NVL(count(fild),0)end 第二个,casewhen fild='3' then NVL(count(fild),0)end 第三个,c.namefrom a group by name
------解决方案--------------------
decode
------解决方案--------------------
nvl() 或者 decode()