查询转换列中的行

时间:2011-06-23 05:24:29

标签: sql oracle oracle11g pivot

我想将行转换为列。 IE:采取以下措施:

HOPPER_CLOSE_TIME     HOPPER_OPEN_TIME     SR_NO    CAL_DONE  PARTIAL_CALC_DONE_TIME
------------------------------------------------------------------------------------
23-06-2011 10:26:41   23-06-2011 10:29:23  535100   2         23-06-2011 10:28:41

我希望这样

HOPPER_CLOSE_TIME         23-06-2011 10:26:41
HOPPER_OPEN_TIME          23-06-2011 10:29:23
SR_NO                     535100
CAL_DONE                  2
PARTIAL_CALC_DONE_TIME    23-06-2011 10:28:41

1 个答案:

答案 0 :(得分:-1)

select HOPPER_CLOSE_TIME  new_column_name from table1 where your_condition_here
union all
select  HOPPER_OPEN_TIME  new_column_name from table1 where your_condition_here
union all
select  SR_NO             new_column_name from table1 where your_condition_here
union all
select CAL_DONE           new_column_name from table1 where your_conidtion_here
union all
selectnPARTIAL_CALC_DONE_TIME new_column_name from table1 where your_condition_here