多条件情况查询
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