有一张表rbb 里面有scsj,ty,yy 把整张表输出 select * from rbb,我现在想输出时进行筛选 scsj<>24时TY等于空SCSJ=24时TY等于原有数值不变,其它都不变输出整张表!
下面的几个我都试了 说是少关键字 运行不了 这是为什么呢
2009-04-16 11:04
提问者采纳
sql的select里没有if else,有类似的case when then else end ------------------- select scsj, case scsj when 24 then ty else null end as ty, yy from rbb
-
提问者评价
-
select scsj, case scsj when 24 then ty else null end as ty, yy from rbb
评论(3)
5
4
2015-9-16 20:38
得時勿失
![](https://i-blog.csdnimg.cn/blog_migrate/a5780a9bede51f866bc9896a46581bb8.jpeg)
2011-7-19 14:35
lemonzone2010
![](https://i-blog.csdnimg.cn/blog_migrate/a6adb42a7254239a309fcb9bf39b61fe.jpeg)
2010-9-11 17:51
x60024577
![](https://i-blog.csdnimg.cn/blog_migrate/15e5a4a637fe341ea472dda09bb63c46.jpeg)
2009-04-16 10:52
qq82557566
六级
if sc>24
begin
select * from rbb
end
此上是查询sc大于24的数据。。
后面的一样。。。
begin
select * from rbb
end
此上是查询sc大于24的数据。。
后面的一样。。。
评论
0
2
2009-04-16 10:58
javagarden
九级
select * from rbb
where case when scsj <> 24 then ty = null
else scsj = 24 then ty
end
where case when scsj <> 24 then ty = null
else scsj = 24 then ty
end