select kcbl=case
when isnull(kc,0)<>0
then
case
when isnull(xs,0)<>0 then
isnull(kc,0)/isnull(xs,0)
else
begin
'-'
end
end
else
0
end
from t为啥不行?
when isnull(kc,0)<>0
then
case
when isnull(xs,0)<>0 then
isnull(kc,0)/isnull(xs,0)
else
begin
'-'
end
end
else
0
end
from t为啥不行?
from 表
from t
else v end v order by a
else v end v from table order by a
create table t1(a int,v int)
insert t1 values(1,0)
insert t1 values(2,3)
insert t1 values(3,4)
insert t1 values(4,0)select a,(case when v = 0 then '-' else cast(v as varchar) end) as v
from t1a v
----------- ------------------------------
1 -
2 3
3 4
4 -(所影响的行数为 4 行)
这个最好是在前台做显示格式。不要在查询时做。查询语句这样就行:select * from t
else cast(应收增加 as varchar(10)) end
from test
WHEN when_expression THEN result_expression
[ ...n ]
[
ELSE else_result_expression
]
END CASE 搜索函数:CASE
WHEN Boolean_expression THEN result_expression
[ ...n ]
[
ELSE else_result_expression
]
END