码迷,mamicode.com
首页 > 数据库 > 详细

多条件情况查询,sql select case when when else

时间:2014-12-31 15:54:35      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

多条件情况查询

 

SELECT
技术分享     Title,
技术分享    ‘Price Range‘ =
技术分享    CASE
技术分享        WHEN price IS NULL THEN ‘Unpriced‘
技术分享        WHEN price < 10 THEN ‘Bargain‘
技术分享        WHEN price BETWEEN 10 and 20 THEN ‘Average‘
技术分享        ELSE ‘Gift to impress relatives‘
技术分享    END
技术分享FROM titles

 

select *,case when ActualTime is null then null  when PlanTime  is null then null  else   ISNULL(ActualTime, 0) - ISNULL(PlanTime, 0)   end    as   Difference
         from KPI_TaskActivities

多条件情况查询,sql select case when when else

标签:

原文地址:http://www.cnblogs.com/szlixin/p/4195862.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!