Solved

PLSQL - rotate information (PIVOT)

Posted on 2014-10-27
3
180 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 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Queries 15 48
How to free up undo space? 3 50
Oracle Listener Not Starting 11 53
Oracle Forms 10g: How-To Prevent a Commit of 1 Record in Master-Detail block. 3 53
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

829 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