0

我需要一个可以转换的 sql select 语句

1
2
3
4

进入1 2 3 4

在运行 oracle 10 数据库时不使用 PIVOT 函数。在互联网上搜索了很多,但令人惊讶的是什么也没找到。

一点帮助?

4

1 回答 1

1

您可以pivot使用交叉连接几乎同样有效地进行操作:

select max(case when seqnum = 1 then t.col end) as col1,
       max(case when seqnum = 2 then t.col end) as col2,
       max(case when seqnum = 3 then t.col end) as col3,
       max(case when seqnum = 4 then t.col end) as col4
from (select t.*, row_number() over (order by NULL) as seqnum
      from t
     ) t
于 2013-06-22T14:29:17.913 回答