读书人

条件判断Sql

发布时间: 2012-01-31 21:28:41 作者: rapoo

条件判断Sql求助
如何在sql语句中用判断,
比如当前时间小于某值,select a as hhh,
大于某值,select b as hhh,
写到一个select中,怎么写

[解决办法]
select hhh=case when dt <getdate() then 'a '
else 'b ' end from t
[解决办法]
select (case when getdate() < '2007-1-1 ' then a when getdate()> '2007-7-7 ' then b end) as hhh
from table
[解决办法]
case
[解决办法]
select 'a ' , 'hhh '= case when getdate() < dt then (select a as hhh) else (select b as hhh) end
from table

读书人网 >SQL Server

热点推荐