?
Solved

PLSQL - rotate information (PIVOT)

Posted on 2014-10-27
3
Medium Priority
?
184 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

770 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