日期:2014-05-19  浏览次数:20520 次

条件判断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