日期:2014-05-17  浏览次数:20835 次

50分求一条SQL语句!
现在有表A如下
ID       Name   Level
1         aa         1
2         bb         0
3         cc         1
4         dd         0
其中Level字段1表示紧急,0表示普通
现在求一条Select的SQL语句,希望得到如下的表数据
ID       Name     Level
1         aa         紧急
2         bb         普通
3         cc         紧急
4         dd         普通
//也就是把Level的0,1转化为紧急和普通
请高手赐教,谢谢

------解决方案--------------------
select
id,
name,
decode(level,1, '紧急 ',0, '普通 ',null) as level
from 表A
------解决方案--------------------
如果level有其它的值,直接decode(level,1, '紧急 ',0, '普通 ',....)就行了
------解决方案--------------------
select t.Name,Case when t.Level = 1 then '紧急 ' ELSE '普通 ' end as Level from A t;