The Perfect Day

分享技术,编写未来

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

若b列的值都为1则返回Y,否则返回X

declare @t table(a int,b int)
insert @t
select 1,1 union all 
select 2,1 union all 
select 3,1 union all 
select 4,0 

select b=case when exists(select b from @t where b<>1then 'X' else 'Y' end 
 
result:   b
        -------
            X
posted on 2006-11-09 11:45  StephenJu  阅读(531)  评论(0编辑  收藏  举报