How to convert the column lines

I need to convert my output lines of sql for the column as a pivot to 11g

Please give me the example of this

check out this link

http://nimishgarg.blogspot.com/2010/06/Oracle-pivot-data-rows-to-columns.html

request for 10g would be

Select *.
(select job,
Sum (decode(DEPTNO,10,SAL)) dept10,
Sum (decode(DEPTNO,20,SAL)) dept20,
Sum (decode(DEPTNO,30,SAL)) dept30,
Sum (decode(DEPTNO,40,SAL)) dept40
from scott.emp
Working Group)
order by 1;

Tags: Database

Similar Questions

  • How to convert the column of ROW using DBMS_REDIFINITION object type column

    Hi all
    Suppose I have the following table to convert:
    create table customer as select customer_id cid, cust_first_name name, cust_address street from customers;
    alter table customer modify cid primary key;
    I created the table based on the customers of the OE schema table, while the street column has cust_address_typ with the following attribute object type
    SQL> describe cust_address_typ
     Name                                     Null?     Type
     ----------------------------------------------------- -------- ------------------------------------
     STREET_ADDRESS                               VARCHAR2(40)
     POSTAL_CODE                                   VARCHAR2(10)
     CITY                                        VARCHAR2(30)
     STATE_PROVINCE                               VARCHAR2(10)
     COUNTRY_ID                                   CHAR(2)
    I want to convert the object attribute adresse_rue in a column of RDM. Consider the following temporary table:
    CREATE TABLE INT_CUSTOMER(
    CID NUMBER,
    NAME VARCHAR2(30),
    street varchar2(100)
    );
    First of all, I checked if the table can be redefined:
    --Verify if the table can be redefined
    BEGIN
    DBMS_REDEFINITION.CAN_REDEF_TABLE('OE','CUSTOMER',DBMS_REDEFINITION.CONS_USE_PK);
    END;
     4  /
    
    PL/SQL procedure successfully completed.
    But when I started the redefinition, I got an error:
    BEGIN
    DBMS_REDEFINITION.START_REDEF_TABLE(
    uname => 'OE',
    orig_table => 'CUSTOMER',
    int_table => 'INT_CUSTOMER',
    col_mapping => 'CID CID, NAME NAME, STREET CUST_ADDRESS_TYP(STREET_ADDRESS)'
    );
    END;
      9  /
    BEGIN
    *
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 52
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 1646
    ORA-06512: at line 2
    What seemed to be the problem?

    Best regards
    Val

    Published by: Valerie good-natured October 9, 2011 21:43

    Have you tried this one:

    BEGIN
    DBMS_REDEFINITION.START_REDEF_TABLE(
    uname => 'OE',
    orig_table => 'CUSTOMER',
    int_table => 'INT_CUSTOMER',
    col_mapping => 'CID CID, NAME NAME,"CUSTOMER".STREET.STREET_ADDRESS STREET'
    );
    END;
    

    Looking at your trace file, I claim that when you use the call above to START_REDEF_TABLE, the inner workings of this procedure will create this SQL statement:

    select CID CID, NAME NAME,"CUSTOMER".STREET.STREET_ADDRESS STREET from "OE"."CUSTOMER" "CUSTOMER"
    

    (You can prove or disprove my claim by tracing it ;-)))

    And this statement has had an alias - even if the alias is the same as the name of the table...

  • How to convert the column online

    Hello

    Do is samble of my data, I need to convert columns into rows

    create table uload_table (id1 number, tidset varchar2(200));
    
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,1);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,2);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,3);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,4);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,5);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,7);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,8);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,10);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,2);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,3);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,4);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,5);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,8);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,9);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,10);
    select * FROM UNLOAD_TABLE ;
    ID1      TIDSET
    ----- ----------   
    1     1
    1     2
    1     3
    1     4
    1     5
    1     7
    1     8
    1     10
    2     2
    2     3
    2     4
    2     5
    2     8
    2     9
    2     10
    I need the result to be as below.
    ID1      TIDSET
    ----- ----------   
    1     ;1;2;3;4;5;7;8;10
    2     ;2;3;4;5;8;9;10
    any help please,.

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e26088/functions089.htm#SQLRF30030

    Concerning

    Etbin

  • convert the column to a string name

    pls help me.

    I need to know how can I convert the column to a string name because I can not insert the column name into my table.


    for matrix (SELECT nom_de_colonne
    OF all_col_comments@myDBLink
    WHERE UPPER (trim (table_name)) = "ROLEMATRIX")
    loop
    INSERT INTO myTABLE (myColumn)
    VALUES (matrix.column_name);
    end loop;


    my error:
    ORA-00984: column not allowed here

    which line you are confronted with error, because I've also tested this, his work on my side!

  • How to add the column to Adobe flex mxml or actionsctpt mx:DataGrid?

    I have the simple mxml code

    <mx:DataGrid id="DGG"
                
    editable="true">
       
    <mx:dataProvider>
           
    <mx:Object scheduledDate="4/1/2006"/>
       
    </mx:dataProvider>
    </mx:DataGrid>
    <mx:Button id="SetBut"
              
    label="Set Array as Data Provider"
              
    click="SetDP(); AddBut.visible = true;"
              
    x="100.5"
              
    y="164"
              
    width="211"/>
    <mx:Button id="AddBut"
              
    label="Add a column!"
              
    click="AddCol();"
              
    x="100.5"
              
    y="194"
              
    width="211"
              
    visible="false"/>
    <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.collections.ArrayCollection;

            [Bindable]
            public var MyAC:ArrayCollection=new ArrayCollection([{scheduledDate: "4/1/2006", homeTeam: "Chester Bucks"}]);

            public function SetDP():void
            {
                DGG.dataProvider=MyAC
            }

            public function AddCol():void
            {
                MyAC.addItem({scheduledDate: "4/5/2007", homeTeam: "Long Valley Hitters", Umpire: "Amanda Hugenkis"});
                DGG.columns.push(new DataGridColumn("Umpire"));
            }
        ]]>
    </mx:Script>

    I want to add lines to my datagrid table how do such thing?

    How to add the column to Adobe flex mxml or actionsctpt mx:DataGrid?

    (You can place this code in a Flash or AIR application - it compiles without error, but will not add any columns =)

    Change this:

    public void SetDP (): void
    {
    DGG.dataProvider = MyAC
    MyAC.addItem ({scheduledDate: "05/04/2007", homeTeam: "long hitters Valley", umpire: "Amanda Hugenkis"});
    }
               
    public void AddCol (): void
    {
    var dgc:DataGridColumn = new DataGridColumn ("Umpire");
    var ca:Array = DGG.columns;
    CA.push (DGC);
    DGG.columns = ca;
    }

    Dany

  • How to recover the second line of a table

    Hello

    Could someone let me know how to recover the second line of a table without using the coumn the names of columns in the table.

    By default the table EMP or used in the case of scott connection can be used as an example of table.


    Concerning
    select e.* from(
    select e.*,  rownum rn from emp e)e
    where e.rn =2
    

    did you expect that?

  • How to keep the Safari line at the top of my screen to disappear?

    How to keep the Safari line at the top of my screen to disappear?

    See the toolbar of Safari mode full screen?

    Launch Safari.

    Click on the Green navigation button to enter full screen mode.

    Move the mouse to the top of the screen.

    When the menu bar and the toolbar drop-down, click on 'View' in the menu bar of Safari.

    In the drop-down menu choose «Always see the toolbar in full screen»

  • How to convert the precision extended float to float in C++

    Hello

    Could someone me please how to convert the extended precision (floatExt) float normal float in C++?

    What is the difference in the float between Labview and C++ data type?

    When I tried to receive a range of float of a function of the DLL generated by Labview in C++, data are bad.

    Thank you

    Victor King

    You can search for numeric data types in LabVIEW help for more information on the different types of data. Before sending the data to the C++ application, you can use the function of Double precision on digital / range of Conversion to convert number to Double precision.

  • How to convert the date in milliseconds?

    Hi all

    Can I know how to convert the date in milliseconds?

    My current datetime like this Formate

    QDateTime::currentDateTime (m:System.NET.SocketAddress.ToString ("MMMM dd, yyyy HH"))

    Seconds since January 1, 1970

    http://Qt-project.org/doc/Qt-4.8/QDateTime.html#toTime_t

    Sinds milliseconds January 1, 1970

    http://Qt-project.org/doc/Qt-4.8/QDateTime.html#toMSecsSinceEpoch

  • How to keep the columns of history in capital letters?

    Hello

    Is there a way to convert the columns that are marked as columns of history (ex: Created_By, Updated_By) uppercase and then store them in the database table? Once these columns are marked as history columns, Set accessor methods are not generated in the EOImpl class, and whenever a record is created or updated, the created_by and updated_by on these recordings are filled automatically by the framework using the name of securityContext so my interpretation is not bad.

    Is it possible to override this to ensure that whenever a transaction takes place, these columns are always inserted/updated on top of case?

    Thank you.

    You will need to return username converted to uppercase if the kind of story is HISTORY_CREATE_USER.

    So it should look like this:

    protected Object getHistoryContextForAttribute(AttributeDefImpl attributeDefImpl){
        if(attributeDefImpl.getHistoryKind()==AttributeDefImpl.HISTORY_CREATE_USER){
            return ADFContext.getCurrent().getSecurityContext().getUserName().toUpperCase();
        }else{
            return super.getHistoryContextForAttribute(attributeDefImpl);
        }
    }
    

    Dario

  • How to add the new line 'Total' to a report?

    Hello

    I built a report within the region. I can get the total by checking the 'sum', but I need the word 'total' showing on the same vintage with the total amount. How can I achieve that? or in any different way how to create the new line to show total?

    Source debit credit

    A 45 44

    45 56 B

    90 100

    Thank you

    Victor

    Hello

    For the classic report show the sum.

    Go to the report attributes and click the box check the amount that you want to total.

    If you still face any problem-

    Please go to the

    http://Apex.Oracle.com/

    Workspace - WS_SUNITI

    User name: Test

    Password: 1234

    82863 application ID.

    Name of the tab - PSVANS3

    Page no 5

    Kind regards

    Director

  • Please how to convert the photo to the second

    2012-Kia-Rio-SX-side1.jpg11707850_10153403835594354_514303523436587694_n-1.jpg

    Please guys how to convert the kia rio pictures the second perfect like this, and with any program, I know that all steps in details please its very important

    That looks just like you would use the tool pen to redraw on the image and create shape layers (black areas). It could be done in Photoshop or Illustrator.

    Using Photoshop | Draw with the pen tools

  • Hello, I have a full desktop in Adobe Muse, site and I want to convert it into a version Tablet &amp; phone, then, how would convert the site Office to Tablet &amp; phone to copy the entire office content and site structure? Thanks for any help.

    Hello, I have a full desktop in Adobe Muse, site and I want to convert it into a version Tablet & phone, then, how would convert the site Office to Tablet & phone to copy the entire office content and site structure? Thanks for any help.

    You can not automatically convert. Click on the "tablet" or "Phone" at the top of your plan view to create these versions.

    You can then copy and paste on any content you want has more of your office.

  • How to list the columns for a view

    Dear experts

    I know how to list the columns in a table. This easy by querying the data USER_TAB_COLUMNS dictionary.

    But my problem is how to issue a query that returns the columns for a view?

    Thanks in advance

    USER_TAB_COLUMNS stores the metadata for both views.

    Select * from user_tab_columns where table_name = 'YOUR_VIEW_NAME"of order of column_id.    -Replace with your view_name (mandatory course)

    See you soon,.

    Manik.

  • How to check the column updated whereby the package or procedure?

    Hi all

    Can someone help me how to check the column updated by which the package or procedure

    A.Mahesh

    Hello.

    You can check what object is a reference to the table of the column:

    Select *.

    of all_dependencies d

    where d.REFERENCED_NAME = '. '

    And you can find all the links to the object source data column:

    Select *.

    of s all_source

    where s.name = "."

    and s.OWNER = '. '

    and s.TYPE = "."

    and as s.TEXT '%%'

Maybe you are looking for