当前位置: 代码迷 >> Oracle开发 >> oralce中如何一行转成一列
  详细解决方案

oralce中如何一行转成一列

热度:89   发布时间:2016-04-24 07:00:32.0
求助:oralce中怎么一行转成一列
利用dual构建虚表   “select '1','高','2','中','3','低' from dual”  如下:



需要等到结果:

等级代码  等级
1         高
2         中
3         低
java oralce

------解决方案--------------------
select '1','高' from dual union all
select '2','中' from dual union all
select '3','低' from dual;
------解决方案--------------------
sys@ORCL> ed
Wrote file afiedt.buf

  1  with
  2    t as (
  3          select '1' "等级代码",'高' "等级" from dual union all
  4          select '2','中' from dual union all
  5          select '3','低' from dual
  6         )
  7* select * from t
sys@ORCL> /

等级代码             等级
-------------------- --------------------
1                    高
2                    中
3                    低
  相关解决方案