Solved

PLSQL - rotate information (PIVOT)

Posted on 2014-10-27
3
174 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
3 Comments
 
LVL 76

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 48

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now