case 正确写法问题
declare @type as int
set @type=3
由
SELECT
CASE @type
WHEN 1 THEN 'A '
WHEN 2 THEN 'B '
WHEN 3 THEN 'C '
WHEN 4 THEN 'A '
WHEN 5 THEN 'B '
WHEN 6 THEN 'A '
END
如何简写为这种效果?
SELECT
CASE @type
WHEN 1,4,6 THEN 'A '
WHEN 2,5 THEN 'B '
WHEN 3 THEN 'C '
END
------解决方案--------------------SELECT
CASE
WHEN @type in(1,4,6) THEN 'A '
WHEN @type in(2,5) THEN 'B '
WHEN @type in(3) THEN 'C '
END