您的位置:首页 > 博客中心 > 数据库 >

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

时间:2022-03-14 04:28

多条件情况查询

 

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

热门排行

今日推荐

热门手游