我有一个视图report
,其他列旁边有一列status
。目前status
包含0,1或-1。我希望它相应地“通过”,“警告”和“失败”。有没有办法可以做到?感谢
目前我的查询如下:
CREATE VIEW Test_Result_Information AS
SELECT
r.ResultID,
r.TestID,
Name,
Descrption,
ExecutedOn,
Expires,
r.ResultCode,
ResultType,
ResultMessage,
Vars
FROM Results AS r, TestResultPool AS p, TemplatedTests AS t
WHERE r.TestID = p.TestID AND p.TestID = t.TestID AND r.ResultCode = p.ResultCode
答案 0 :(得分:1)
这样做:
SELECT CASE when status = 0 then 'pass'
when status = 1 then 'warning'
when status = -1 then 'fail'
end as [status]
这应该可以解决问题,假设我的语法正确。