数据库某个字段以及里面的数据为:
state
0
1
2
3
1其中的0,1,2,3都是有它特定的含义的,比如0:未提交1:已提交 2:已审批 3:已审核现在要求select出来的结果如下:
state
未提交
已提交
已审批
已审核
已提交请教具体语句该怎么来实现?(可使用存储过程)
state
0
1
2
3
1其中的0,1,2,3都是有它特定的含义的,比如0:未提交1:已提交 2:已审批 3:已审核现在要求select出来的结果如下:
state
未提交
已提交
已审批
已审核
已提交请教具体语句该怎么来实现?(可使用存储过程)
when state = 1 then '已提交'
when state = 2 then '已审批'
when state = 3 then '已审核'
end state
from tb
state= case state when 0 then '未提交'
when 1 then '已提交
when 2 then '已审批'
else '已审核' end
from
tb
select
state= case state when 0 then '未提交'
when 1 then '已提交'
when 2 then '已审批'
else '已审核' end
from
tb
insert into tb values(0)
insert into tb values(1)
insert into tb values(2)
insert into tb values(3)
insert into tb values(1)
goselect case when state = 0 then '未提交'
when state = 1 then '已提交'
when state = 2 then '已审批'
when state = 3 then '已审核'
end state
from tbdrop table tb/*
state
------
未提交
已提交
已审批
已审核
已提交(所影响的行数为 5 行)
*/
select state=case
when state=0 then '未提交'
when state=1 then '已提交'
when state=2 then '已审批'
when state=3 then '已审核'
end
from tableName