当字段值不可枚举的时候怎么实现行转列?

czmmiao 2011-02-21

当字段值不可枚举的时候怎么实现行转列?

数据如下:


SQL> select count(*) from test_1;

  COUNT(*)
----------
        99
SQL> desc test_1;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NAME                                               VARCHAR2(10)
 ID                                                 NUMBER(5)

SQL> select * from test_1 where id<=5;

NAME                                   ID
------------------------------ ----------
A                                       1
A                                       2
A                                       3
A                                       4
A                                       5
其中id为1-99如何转换成


NAME   ID1      ID2      ID3            .........            ID98         ID99

A              1         2           3                                        98             99

albb0608 2011-03-30
用过程吧,用过程写的话感觉有思路
lumi 2012-01-31
先查出来有多少种可能,然后用动态sql拼装吧!好像没别的办法了
Global site tag (gtag.js) - Google Analytics