这可能是一个新手问题,但仍然......
我们都熟悉Oracle的解码和案例,例如
select
decode (state,
0, 'initial',
1, 'current',
2, 'finnal',
state)
from states_table
Run Code Online (Sandbox Code Playgroud)
或者使用CASE的同类事物.
现在让我们说我有一个具有相同值的表:
state_num | state_desc
0 | 'initial'
1 | 'current'
2 | 'finnal'
Run Code Online (Sandbox Code Playgroud)
有没有办法我可以使用此表作为解码资源进行相同的查询?请注意,我不想联合表来访问其他表中的数据...我只是想知道是否有一些我可以用来做某种事情decode(myField, usingThisLookupTable, thisValueForDefault).
您可以使用子查询代替联接,即
select nvl(
(select state_desc
from lookup
where state_num=state),to_char(state))
from states_table;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9195 次 |
| 最近记录: |