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

条件判断Sql

2012-01-31 
条件判断Sql求助如何在sql语句中用判断,比如当前时间小于某值,selectaashhh,大于某值,selectbashhh,写到一

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

热点排行