首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

关于查询的一个小疑点 很简单的 只是偶忘了如何写 明早送分

2012-02-06 
关于查询的一个小问题 很简单的 只是偶忘了怎么写 明早送分有一个表TEMP有2个字段a,b我想这么查询如果a为

关于查询的一个小问题 很简单的 只是偶忘了怎么写 明早送分
有一个表   TEMP   有2个字段   a,b  
我想这么查询     如果a   为空或0的话   则查询结果为b  
如果a   不为空或0的话   则结果为b/a  
要求用一个select   语句写出来。。。。。。。。。。

select   (when   a=0   then   b   when   a   is   null   then   b   else   b/a   )as   ttt   from   Temp      
大概就是这么个意思吧     反正我忘了怎么写了

不要笑偶太菜哦。。。。。。。。。。。。


[解决办法]
Select Case When a = 0 Or A Is Null Then b Else b/a End As ttt From [Temp]
[解决办法]
select case when isnull(a,0)=0 then b else b/a endas ttt from Temp
[解决办法]
case when isnull(a,0)=0 then b else b/a end
[解决办法]
endas
-->
end as

[解决办法]
select c = case when isnull(a, 0) = 0 then b else b/a end
from 表
[解决办法]
我想了一下,我还是不回复了.

看来我是对的~~ 呵呵
[解决办法]
select case when a= '0 ' or ais null then a/b else a end as ab from temp
[解决办法]
case when isnull(a,0)=0 then b else b/a end

[解决办法]
select c=case when isnull(a,0)=0 then b else b/a end
[解决办法]
select c=case when isnull(a,0)=0 then b else b/a end
from temp

热点排行