Solved

PLSQL - rotate information (PIVOT)

Posted on 2014-10-27
3
183 Views
Last Modified: 2014-10-28
Hi experts:

The information has been save horizontally
codigoMaterialReal      Enero      Febrero      Marzo      Abril      Mayo       Junio
592025000040252               11.6      11.7                 12.7           13.7          14.7      15.7
600017000030044             12.78      12.78      12.78      12.8      12.78      12.78

I need to rotate,like this
592025000040252      11.6
592025000040252      11.7
592025000040252      12.7
592025000040252      13.7
592025000040252      14.7
592025000040252      15.7
0
Comment
Question by:enrique_aeo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40407513
What you want is UNPIVOT.

try this:
drop table tab1 purge;

create table tab1(
codigoMaterialReal number, Enero number, Febrero number, Marzo number, Abril number, Mayo number, Juni number
);

insert into tab1 values(592025000040252,11.6,11.7,12.7,13.7,14.7,15.7);
insert into tab1 values(600017000030044,12.78,12.78,12.78,12.8,12.78,12.78);
commit;

col codigoMaterialReal form 99999999999999999
select codigoMaterialReal, month
from
(
    (
        select codigoMaterialReal, Enero, Febrero, Marzo, Abril, Mayo, Juni
	from tab1
    )
    unpivot
    (
        month
        for mymonth in
            ( Enero, Febrero, Marzo, Abril, Mayo, Juni)
    )
)
/

Open in new window

0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40407636
If you retain only this:

592025000040252      12.7

how will you know which month that represents?
0
 

Author Comment

by:enrique_aeo
ID: 40408436
i have a sequence
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question