Solved

PLSQL - rotate information (PIVOT)

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
dbms_crypto.decrypt   errors out 6 43
Oracle DBLINKS From 11g to 8i 3 63
Read XML values 8 54
running myfile.SQL from command line SQLPLUS 12c does not exit. 7 34
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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 syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

761 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