Is this a good scenario for MSSQL CASE statement?
This question already has an answer here:
尽管你最多只需要一个AS
来给这个列命名,但你可以使用这样的语法(当然,我已经想出了一些值来说明选项):
SELECT id,
CASE
WHEN statusid IN (1,20,24) THEN 'red'
WHEN statusid IN (2,30,34) THEN 'yellow'
WHEN statusid 8 THEN 'orange'
WHEN statusid > 35 THEN 'green'
ELSE 'unrecognised'
END AS ColorName,
statusid
FROM dbo.table
链接地址: http://www.djcxy.com/p/94348.html
上一篇: SQL视图不接受子条款
下一篇: 这是MSSQL CASE语句的好场景吗?