Pivot Query on Oracle 10g

Table Structure
GRP_NR Values
1 A
1 B
2 A
2 B
2 C
3 A
3 B
3 C
N A
N B
N C
I would like to convert the above structure into the following. I prefer to have it as sql query, but open to plsql solution too.
1 2 3 ..................... N
A A A ..................... A
B B B ..................... B
. C C ..................... C
I am finding it quite a challenge to do it. especially to make it dynamic.
I will appreciate your help.

With model clause.
Regards salim.
select GRP_NR, substr( string, 2 ) as string
from t
model
return updated rows
partition by ( GRP_NR )
dimension by ( row_number() over (partition by GRP_NR ORDER BY val asc) as position )
measures ( cast( val as varchar2(1000) ) as string )
rules
upsert
iterate(1000 )
until ( presentv(string[iteration_number+2],1,0) = 0 )
( string[0] = string[0] || ',' || string[iteration_number+1] )
order by GRP_NR ;
SQL> with t as (
  2  select 1 GRP_NR, 'A' val from dual union all
  3  select 1 ,'B' val from dual union all
  4  select 2 ,'A' val from dual union all
  5  select 2 ,'B' val from dual union all
  6  select 2 ,'C' val from dual union all
  7  select 3 ,'A' val from dual union all
  8  select 3 ,'B' val from dual union all
  9  select 3 ,'C' val from dual )
10  select GRP_NR, substr( string, 2 ) as string
11  from t
12  model
13  return updated rows
14  partition by ( GRP_NR )
15  dimension by ( row_number() over (partition by GRP_NR ORDER BY val asc) as position )
16  measures ( cast( val as varchar2(1000) ) as string )
17  rules
18  upsert
19  iterate(1000 )
20  until ( presentv(string[iteration_number+2],1,0) = 0 )
21  ( string[0] = string[0] || ',' || string[iteration_number+1] )
22  order by GRP_NR ;
    GRP_NR STRING
         1 A,B
         2 A,B,C
         3 A,B,C
SQL>

Similar Messages

  • Pivot function in Oracle 10g???

    Hello everybody,
    at the beginning of the week I had a simple problem (I thought that...), but now after trying and trying, I can't find a solution for it. First of all I'm working on Oracle 10g with the version 10.2.0.4.0. I can't change the version, it's standard in the whole company...
    At the beginning I have a table like the following one, but please note, that the compartment, the type and the amount are flexible and can change at any time:
    comp type amount
    a1 6280 10
    a2 6280 20
    a2 4810 15
    a2 1147 12
    a3 6280 33
    Now I want the table to look like this:
    a1 a2 a3
    1147 0 12 0
    4810 0 15 0
    6280 10 20 33
    A simple question in Excel for example, I just use the pivot function and have it fixed within 10seconds. But how can I do sth. like this in Oracle with simple SQL? Or it can be PL/SQL too, cause I will use this in an APEX application.
    Can you please give me a hint or a solution? But as stated before a1, a2, a3 are just examples it is possible that tomorrow a4, a5 and so on are coming. If it is necessary I can also create additional tables and views of course!
    Thanks for your help!
    Regards
    hoge

    Hi Hoge!
    Here is your solution:
    SELECT TYPE,
           sum(a1) AS a1,
           sum(a2) AS a2,
           sum(a3) AS a3
      FROM (SELECT TYPE,
                   decode(comp, 'a1', amount, 0) AS a1,
                   decode(comp, 'a2', amount, 0) AS a2,
                   decode(comp, 'a3', amount, 0) AS a3
              FROM test)
      GROUP BY TYPE
      ORDER BY TYPE; And here is my test case setup:
    CREATE TABLE test
        (comp VARCHAR2(255),
         TYPE NUMBER,
         amount NUMBER);
    INSERT INTO test(comp, TYPE, amount) VALUES('a1', 6280, 10);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 6280, 20);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 4810, 15);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 1147, 12);
    INSERT INTO test(comp, TYPE, amount) VALUES('a3', 6280, 33);
    commit;Best regards,
    Matt

  • Issue with "Select Distinct" query in Oracle 10g against Oracle 9i

    Hi,
    I would appreciate if some one help me here because it is really urgent.
    We are upgrading our database from 9i to 10g.
    There are the "Select distinct" queries in the code which populated the grid on the applications screens. We found a difference in 9i and 10g the way the result is populated for these queries. If "Select Distinct" query wihtout a order by clause is executed in 9i then the result is automatically sorted. But Oracle 10g does not do this.
    We can change the queries adding order by clause but we are almost at the end of the testing and want to know if there is any way that we can do this from database settings. Would there be any impact of these settings change on overall operation of Oracle 10g?
    I would appreciate if some one can help me here.
    Thanks,
    Dinesh

    then the result is automatically sorted.No. Oracle may have done a sort operation to perform the distinct, but it still did not guarantee the order of your results.
    In 10g and in 9i, if you want your results in a certain order you must use order by.

  • 11G Pivot Query with Oracle EBS

    Hello all,
    We are trying to use the 11G pivot query function with data from Oracle E-Business Suite. We have an 11G database installed with our Oracle APEX. We cannot seem to get the pivot function to work. At a glance, would anyone be able to see any glaring errors in our syntax. I am not certain it is possible to provide test data so...
    We are trying to have column headings with the Period Names SEP-08 OCT-08 NOV-08, with rows of segment2 007751 and accounted_dr as the dataset.
    When we run the sql we get an error ORA-00904: "PERIOD_NAME": invalid identifier.
    Any help or insight would be greatly appreciated.
    select * from (
    select segment2, accounted_dr, period_name
    from gl_je_lines a, gl_code_combinations b
    where b.code_combination_id = a.code_combination_id
    and segment2 = '007751')
    pivot
    sum(accounted_dr)
    for period_name in ('SEP-08','OCT-08','NOV-08')
    group by segment2, period_name

    lilhelp wrote:
    Hello all,
    We are trying to use the 11G pivot query function with data from Oracle E-Business Suite. We have an 11G database installed with our Oracle APEX. We cannot seem to get the pivot function to work. At a glance, would anyone be able to see any glaring errors in our syntax. I am not certain it is possible to provide test data Why not?
    >
    We are trying to have column headings with the Period Names SEP-08 OCT-08 NOV-08, with rows of segment2 007751 and accounted_dr as the dataset.
    When we run the sql we get an error ORA-00904: "PERIOD_NAME": invalid identifier.
    Any help or insight would be greatly appreciated.
    select * from (
    select segment2, accounted_dr, period_name
    from gl_je_lines a, gl_code_combinations b
    where b.code_combination_id = a.code_combination_id
    and segment2 = '007751')
    pivot
    sum(accounted_dr)
    for period_name in ('SEP-08','OCT-08','NOV-08')
    group by segment2, period_nameDon't use GROUP BY. When you use PIVOT, the grouping is implied by what is in the PIVOT clause and what is not.
    Try this:
    select    *
    from        (
           select  segment2
           ,       accounted_dr
           ,       period_name
           from       gl_je_lines          a
           ,       gl_code_combinations     b
           where       b.code_combination_id = a.code_combination_id
           and       segment2 = '007751'
    pivot       (
           sum (accounted_dr)
           for period_name in ('SEP-08','OCT-08','NOV-08')
    ;which is just your posted query without the GROUP BY clause.

  • Query  regarding oracle 10g connection in Visual Studio 2005

    Hi ,
    I am having visual studio 2005 installed in my system . when i am adding oracle database connection it is displaying that "use this connection for oracle 7 ,8, 9i versions ..i want to connect oracle 10g database in visual studio 2005. plz tell me how to do that?

    looks like u'r try connecting to oracle using server explorer, just hit OK an then fill in your server name, userid and password.
    server name might be SID defined in your tnsnames.ora, or in the form of //<machine_name>/<service_name>

  • Query Optimization (Oracle 10g)

    Hi All,
    I have written a query. But It's taking around 15 minutes. Can you please check the query and Explain plan of the query and give me the solution for optimize the query.
    Query :
    SELECT *
      FROM temp.r_view
    WHERE cur IN (SELECT p_id_d
                          FROM temp.pm
                         WHERE p_id_h = 'CURRENCY' AND p_txt
                                   = 'EUR')
       AND rec_amt >= 10
       AND r_view.date_exec >
              TO_DATE ((SELECT p_txt
                          FROM temp.pm
                         WHERE p_id_h = 'MONETARY'
                           AND p_id_d = 'LAST_DATE'
                           AND p_id_t = 'S'),
                       'DD-MON-YYYY'
       AND SID NOT IN (
              SELECT gl_sid
                FROM s_wr.p_smst
               WHERE p_gst.p_idc =
                           (SELECT p_txt
                              FROM temp.pm
                             WHERE p_id_h  = 'MONETARY'
                             AND   pm_id_d = 'MONETARY_ID'));
    OPERATION     OPTIONS         OBJECT_NAME      POSITION
    SELECT STATEMENT                        199600
    FILTER                                         1
    HASH JOIN     RIGHT SEMI                    1
    TABLE ACCESS     FULL             PM               1
    VIEW          R_VIEW                               2
    UNION-ALL                                 1
    TABLE ACCESS     FULL             IN_CUST_TEMP       1
    TABLE ACCESS     FULL             RC_REG_WORK       2
    HASH            JOIN                            3
    VIEW                          V_SQ_1               1
    HASH             GROUP BY                            1
    TABLE ACCESS     FULL             TP_MAIN_WORK       1
    TABLE ACCESS     FULL             TP_MAIN_WORK       2
    TABLE ACCESS     FULL             IN_SS_RELOAD       4
    TABLE ACCESS     FULL             CTF_AORD_WORK       5
    TABLE ACCESS     FULL             MANXA_RELOAD       6
    TABLE ACCESS     FULL             STX_FR_PURSE       7
    TABLE ACCESS     BY INDEX ROWID     PM               2
    INDEX             RANGE SCAN     K_PRM             1
    TABLE ACCESS     BY INDEX ROWID     P_GST               2
    INDEX             RANGE SCAN     ID1_P_GST         1
    TABLE ACCESS     BY INDEX ROWID     PM               1
    INDEX             RANGE SCAN     K_PM               1Thank you

    user636482 wrote:
    I have written a query. But It's taking around 15 minutes. Can you please check the query and Explain plan of the query and give me the solution for optimize the query.Since you're already on 10g, please use DBMS_XPLAN.DISPLAY to generate a more meaningful output of the EXPLAIN PLAN command.
    Please read this HOW TO: Post a SQL statement tuning request - template posting that explains what you should provide if you have SQL statement tuning question and how to format it here so that the posted information is readable by others.
    This accompanying blog post shows step-by-step instructions how to obtain that information.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Getting error "Column is not indexed " when executing query on ORACLE 10g

    Hi all,
    When executing the below query im getting the error "ORA-20000:Column is not indexed"
    query:
    select xmlelement("nexml:result",xmlattributes('http://namespaces.nextance.com/nex/xml' as "xmlns:nexml"),xmlelement("nexml:value",count(*))).getClobVal()
    from "permission"
    where ( ((contains(object_value,'(searchDocument) inpath(/permission/action)') > 0)) and ((existsNode(object_value,'/permission[resource/resourcekey/@type[. = "document"]]') = 1)) and ((contains(object_value,'(GeneralUser) inpath(/permission/principal/@name)') > 0)) and ((existsNode(object_value,'/permission[principal/@type[. = "group"]]') = 1)) and ((existsNode(object_value,'/permission[type[. = "allow"]]') = 1)) and ((contains(object_value,'(nexip) inpath(/permission/resource/resourcekey/field/@value)') > 0) or (contains(object_value,'(Corporate) inpath(/permission/resource/resourcekey/field/@value)') > 0) or (contains(object_value,'(ProcurementAgreement) inpath(/permission/resource/resourcekey/field/@value)') > 0) or (contains(object_value,'(Procurement) inpath(/permission/resource/resourcekey/field/@value)') > 0) or (contains(object_value,'(SalesAgreement) inpath(/permission/resource/resourcekey/field/@value)') > 0)) )
    Then after checking some forum, i replaced "contains" with "ora:contains" and executed the query. Now im not getting the first error but got a new error "invalid relational operator"
    So please help me in resolving the errors?
    Thanks in advance.

    Anil kumar wrote:
    Hi,
    Thanks for your reply. Could you please explain your solution in detail?Hi,
    I just have a try...
    create table t (id int,my_lob clob)
    begin
    insert into t values(101,'Oracle redwood shores USA');
    insert into t values (102,'HP palo alto USA');
    insert into t values(103,'Capgemini  FRANCE');;
    end;
    create index my_idx on t(my_lob) indextype is ctxsys.context
    select *
    from t
    where contains(my_lob,'USA',1)>0
    Output
    ID      MY_LOB
    101     Oracle redwood shores USA
    102     HP palo alto USA Hope it helps,
    CKLP

  • How To Write A Matrix Query in Oracle 10g

    Hi All,
    I need to write a query displaying total of each Month and each quarter total. Here is example:
    CREATE TABLE T_CUST_REG(
    CUST_ID NUMBER,
    CUST_NAME VARCHAR2(255),
    REGDATE  DATE);
    INSERT INTO T_CUST_REG VALUES (1, 'A','01-JAN-2012');
    INSERT INTO T_CUST_REG VALUES (2, 'B','01-FEB-2012');
    INSERT INTO T_CUST_REG VALUES (3, 'C','01-MAR-2012');
    INSERT INTO T_CUST_REG VALUES (4, 'D','01-APR-2012');
    INSERT INTO T_CUST_REG VALUES (5, 'E','01-MAY-2012');
    INSERT INTO T_CUST_REG VALUES (6, 'F','01-JUN-2012');
    INSERT INTO T_CUST_REG VALUES (7, 'G','01-JUL-2012');
    INSERT INTO T_CUST_REG VALUES (8, 'H','01-AUG-2012');
    INSERT INTO T_CUST_REG VALUES (9, 'I','01-SEP-2012');
    INSERT INTO T_CUST_REG VALUES (10, 'J','01-OCT-2012');
    INSERT INTO T_CUST_REG VALUES (11, 'K','01-NOV-2012');
    INSERT INTO T_CUST_REG VALUES (12, 'L','01-DEC-2012');
    Output REQUIRED:
    JAN
    FEB
    MAR
    Q1
    APR
    MAY
    JUN
    Q2
    JUL
    AUG
    SEP
    Q3
    OCT
    NOV
    DEC
    Q4
    1
    1
    1
    3
    1
    1
    1
    3
    1
    1
    1
    3
    1
    1
    1
    3
    I am able to create matrix with following query, but issue is how to put Quarter(total) in between.
    Select Count(1), TO_CHAR(REGDATE, 'MON') MON 
    FROM T_CUST_REG T
    GROUP BY TO_CHAR(REGDATE, 'MON');
    Regards

    Hi,
    The query you posted will produce a separate row for each month, not a separate column.  Is that what you want?
    If so, you can add the quarterly totals with GROUPING SETS, like this:
    SELECT    COUNT (*)    AS cnt
    ,         CASE
                  WHEN  GROUPING (TRUNC (regdate, 'MONTH')) = 0
                  THEN  TO_CHAR (TRUNC (regdate, 'MONTH'), 'YYYY MON')
                  ELSE  TO_CHAR (TRUNC (regdate, 'Q'),     'YYYY "Q"Q')
              END          AS label
    FROM      t_cust_reg
    GROUP BY  GROUPING SETS ( (TRUNC (regdate, 'MONTH'))
                            , (TRUNC (regdate, 'Q'))
    Instead of calling TRUNC over and over, you might want to do it just 2 times, in a sub-query, giving aliases to the results, and then use the aliases over and over in the main query.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the exact results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Cannot use Flashback Versions Query in Oracle 10g

    If I want use Flashback Versions Query for one Table in my Database 10.1.0.4 then I receive follow error message:
    500 Internal Server Error
    java.lang.RuntimeException: options is null
         at oracle.sysman.emSDK.jsp.ListBean.applyAttributes(ListBean.java:70)
         at oracle.sysman.emSDK.jsp.ShuttleBean.render(ShuttleBean.java:41)
         at oracle.cabo.ui.BaseUINode.render(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderIndexedChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderIndexedChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderContent(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.render(Unknown Source)
         at oracle.cabo.ui.laf.xhtml.XhtmlLafRenderer.render(Unknown Source)
         at oracle.cabo.ui.BaseUINode.render(Unknown Source)
         at oracle.cabo.ui.BaseUINode.render(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderChild(Unknown Source)
         at oracle.cabo.ui.laf.xhtml.RowLayoutRenderer.renderChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderIndexedChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderIndexedChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderContent(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.render(Unknown Source)
         at oracle.cabo.ui.laf.xhtml.XhtmlLafRenderer.render(Unknown Source)
         at oracle.cabo.ui.BaseUINode.render(Unknown Source)
         at oracle.cabo.ui.BaseUINode.render(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderIndexedChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderIndexedChild(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.renderContent(Unknown Source)
         at oracle.cabo.ui.BaseRenderer.render(Unknown Source)
    .... and so on
    Can any of you help me?

    At what stage did you get this error?. Have you already selected the type of Flash Back Versions Query you want e.g Specifying type of Point in Time (Row Evaluation, Timestamp or SCN) or just when you select from the Action?

  • Query tuning (Oracle 10g)

    Hi
    We are having one query that is having order by clause. If we run with order by then it takes 70-80 min to execute and without order by it takes 1-2 min.
    We cann't remove order by because of business requirements.
    Please suggest me any solution except index, hints (already there).
    Thanks and regards

    What is your database version? If you are using an automated PGA memory management then you might want to check your PGA_AGGREGATE_TARGET.
    You can use V$PGA_TARGET_ADVICE to set up a proper PGA_AGGREGATE_TARGET.
    Read more about PGA Memory management here
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/memory.htm#i49320
    It has a lot to do with Sorting Operations.
    Thanks,
    Karthick.

  • Will the query run Oracle 10g?

    Hi,
    Below is the structure of the emp and dept table.There is a query based on this, please let me know if this query will work ?
    Table EMP
    =========
    EMPID NUMBER PRIMARY KEY,
    NAME
    ADDRESS
    Table DEPT
    ==========
    DEPTNO NUMBER,
    DEPTNAME
    select * from emp where empid in ( select empid from dept where dept_no = 10 ) ;

    Nordik wrote:
    Hi,
    Below is the structure of the emp and dept table.There is a query based on this, please let me know if this query will work ?
    Table EMP
    =========
    EMPID NUMBER PRIMARY KEY,
    NAME
    ADDRESS
    Table DEPT
    ==========
    DEPTNO NUMBER,
    DEPTNAME
    select * from emp where empid in ( select empid from dept where dept_no = 10 ) ;Yes, It will run.
    Oracle will first check if column EMPID exists in DEPT table.
    If it does not, then it checks for the Columns presence in Outer query.
    And this happens, because you did not use Table Alias. Had an Alias been used, the column would have been checked only in the Aliased table.
    Moreover, you would not lose anything but to check the query on a database, would you?
    Easy enough to check this, right?
    create table test_table (col1 number, col2 varchar2(5));
    create table test_table2 (col1 number);
    select *
      from test_table t1
    where col2 in (select col2 from test_table2 t2 where t1.col1 = t2.col1);
    no rows returned

  • Optimisation of query in Oracle 10g

    I have done explain plan for a query and the cost is shoing for the operaions used in the query.
    How can i judge whether the query is taking longer time by cost???
    Please can anyone help on this topic
    Regards

    Hi hkandpal ,
    The query is below:
    SELECT
    0,
    b.to_whse,
    c.item_id,
    b.recv_date,
    decode(a.attribute1,'1',0,1),
    'RECV',
    decode(a.attribute1,'0','DA','1','TIM-DA','2','DE','DA'),
    a.attribute2,
    b.recv_qty1,
    (b.recv_qty1 * b.net_price * b.receipt_exchange_rate),
    0,
    0,
    decode(a.attribute1,'2',a.attribute2,' '),
    a.payvend_id,
    0,
    0,
    0,
    SYSDATE,
    SYSDATE,
    fnd_global.user_id,
    fnd_global.user_id,
    fnd_global.login_id,
    a.of_vendor_id
    FROM xxpepgr_po_recv_dtl b,
    xxpepgr_po_recv_hdr a,
    ic_item_mst c
    WHERE c.inv_type = 'RM'
    AND c.delete_mark = 0
    AND b.item_id = c.item_id
    AND a.recv_id = b.recv_id
    AND a.void_ind = 0
    AND NVL(b.recv_status,0) = 0
    AND a.delete_mark = 0
    -- Commented below code by Akshya.S, OSSI 06-DEC-2006 as part of 11.5.10 upgrade
    --AND    TO_CHAR(a.recv_date,'yyyymmdd') >= v_date1
    --AND    TO_CHAR(a.recv_date,'yyyymmdd') <= v_date2
    -- Commented above code by Akshya.S, OSSI 06-DEC-2006 as part of 11.5.10 upgrade
    -- Inserted below code by Akshya.S, OSSI 06-DEC-2006 as part of 11.5.10 upgrade
    AND ( (a.opm_hist_status = 'N'
    AND TO_CHAR(b.recv_date,'yyyymmdd') >= 20071101 --AKS
    AND TO_CHAR(b.recv_date,'yyyymmdd') <= 20071119 --AKS
    OR( a.opm_hist_status = 'O'
    AND TO_CHAR(a.recv_date,'yyyymmdd') >= 20071101 --AKS
    AND TO_CHAR(a.recv_date,'yyyymmdd') <= 20071119 --AKS
    -- Inserted above code by Akshya.S, OSSI 06-DEC-2006 as part of 11.5.10 upgrade
    -- Commented by Akshya.S, OSSI 28-NOV-2006 as part of 11.5.10 upgrade
    --AND    b.recv_qty1 > 0.001);
    -- Inserted below code by Akshya.S, OSSI 28-NOV-2006 as part of 11.5.10 upgrade
    AND ( b.recv_qty1 > 0.001
         OR b.recv_qty1 < 0.001);
    and below is the explained plan output for the query:
    GETRECV1     11/21/2007 8:46:55 AM          SELECT STATEMENT                                   ALL_ROWS          0          1127     1127     6     2346                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             1     0     1     1127     6     2346                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN                                             2     1     1     1127     5     1920                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN                                             3     2     1     832     762     67818                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          GMI     IC_ITEM_MST_B     5     TABLE     ANALYZED          4     3     1     42     236     2596                         
    GETRECV1     11/21/2007 8:46:55 AM          VIEW               XXTF     XXPEPGR_PO_RECV_DTL     1     VIEW               5     3     2     789     12247     955266                         
    GETRECV1     11/21/2007 8:46:55 AM          UNION-ALL                                             6     5     1                                        
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             7     6     1     490     14     3290                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             8     7     1     490     14     3220                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             9     8     1     476     14     3052                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             10     9     1     476     14     2954                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             11     10     1     462     14     2800                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             12     11     1     448     14     2576                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN                                             13     12     1     434     14     2380                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS     OUTER                                        14     13     1     432     14     2254                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS     OUTER                                        15     14     1     432     14     2156                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS     OUTER                                        16     15     1     432     14     2058                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN                                             17     16     1     432     14     1960                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          PO     PO_LINE_LOCATIONS_ALL     41     TABLE     ANALYZED          18     17     1     225     216     2376                         
    GETRECV1     11/21/2007 8:46:55 AM          VIEW               XXTF          17                    19     17     2     206     1393     179697                         
    GETRECV1     11/21/2007 8:46:55 AM          UNION-ALL                                             20     19     1                                        
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          PO     RCV_TRANSACTIONS     18     TABLE     ANALYZED          21     20     1     90     1369     80771                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             22     20     2     116     24     2208                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN                                             23     22     1     92     24     1800                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          INV     MTL_TRANSACTION_REASONS     21     TABLE     ANALYZED          24     23     1     2     1     10                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          PO     RCV_TRANSACTIONS     19     TABLE     ANALYZED          25     23     2     90     1369     88985                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     BY INDEX ROWID          PO     RCV_TRANSACTIONS     20     TABLE     ANALYZED          26     22     2     1     1     17                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          PO     RCV_TRANSACTIONS_U1          INDEX (UNIQUE)     ANALYZED     1     27     26     1     0     1                              
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          INV     MTL_UNITS_OF_MEASURE_TL_U1          INDEX (UNIQUE)     ANALYZED     2     28     16     2     0     1     7                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          INV     MTL_UNITS_OF_MEASURE_TL_U1          INDEX (UNIQUE)     ANALYZED     2     29     15     2     0     1     7                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          INV     MTL_UNITS_OF_MEASURE_TL_U1          INDEX (UNIQUE)     ANALYZED     2     30     14     2     0     1     7                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          GMI     IC_WHSE_MST     23     TABLE     ANALYZED          31     13     2     2     32     288                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     BY INDEX ROWID          PO     RCV_SHIPMENT_LINES     16     TABLE     ANALYZED          32     12     2     1     1     14                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          PO     RCV_SHIPMENT_LINES_U1          INDEX (UNIQUE)     ANALYZED     1     33     32     1     0     1                              
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     BY INDEX ROWID          INV     MTL_SYSTEM_ITEMS_B     37     TABLE     ANALYZED          34     11     2     1     1     16                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          INV     MTL_SYSTEM_ITEMS_B_U1          INDEX (UNIQUE)     ANALYZED     2     35     34     1     0     1                              
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     BY INDEX ROWID          GMI     IC_ITEM_MST_B     34     TABLE     ANALYZED          36     10     2     1     1     11                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          GMI     IC_ITEM_MST_B_UNQ1          INDEX (UNIQUE)     ANALYZED     1     37     36     1     0     1                              
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          GMI     IC_ITEM_MST_TL_PK          INDEX (UNIQUE)     ANALYZED     2     38     9     2     0     1     7                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          INV     MTL_SYSTEM_ITEMS_TL_U1          INDEX (UNIQUE)     ANALYZED     3     39     8     2     1     1     12                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          PO     RCV_SHIPMENT_HEADERS_U1          INDEX (UNIQUE)     ANALYZED     1     40     7     2     0     1     5                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN                                             41     6     2     299     12233     868543                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          GML     PO_RECV_HDR     30     TABLE     ANALYZED          42     41     1     136     24195     193560                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN     RIGHT OUTER                                        43     41     2     162     12233     770679                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          GML     CPG_ORAGEMS_MAPPING     32     TABLE     ANALYZED          44     43     1     19     5428     43424                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS     OUTER                                        45     43     2     143     12233     672815                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          GML     PO_RECV_DTL     29     TABLE     ANALYZED          46     45     1     141     12233     623883                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          GML     PO_VEND_MST_PK          INDEX (UNIQUE)     ANALYZED     1     47     45     2     0     1     4                         
    GETRECV1     11/21/2007 8:46:55 AM          VIEW               XXTF     XXPEPGR_PO_RECV_HDR     2     VIEW               48     2     2     294     12732     3755940                         
    GETRECV1     11/21/2007 8:46:55 AM          UNION-ALL                                             49     48     1                                        
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS                                             50     49     1     119     634     45648                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS     OUTER                                        51     50     1     119     634     43112                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN                                             52     51     1     119     634     39942                         
    GETRECV1     11/21/2007 8:46:55 AM          VIEW               XXTF          7                    53     52     1     97     634     13948                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH     UNIQUE                                        54     53     1     97     634     25360                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN                                             55     54     1     96     634     25360                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          INV     MTL_ITEM_LOCATIONS     9     TABLE     ANALYZED          56     55     1     6     117     1053                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          PO     RCV_TRANSACTIONS     8     TABLE     ANALYZED          57     55     2     90     634     19654                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          PO     RCV_SHIPMENT_HEADERS     6     TABLE     ANALYZED          58     52     2     21     3152     129232                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          GML     OP_SHIP_MST01          INDEX (UNIQUE)     ANALYZED     1     59     51     2     0     1     5                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          GMI     IC_WHSE_MST_U1          INDEX (UNIQUE)     ANALYZED     1     60     50     2     0     1     4                         
    GETRECV1     11/21/2007 8:46:55 AM          NESTED LOOPS     OUTER                                        61     49     2     174     12098     556508                         
    GETRECV1     11/21/2007 8:46:55 AM          HASH JOIN     RIGHT OUTER                                        62     61     1     174     12098     508116                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          GML     PO_VEND_MST     13     TABLE     ANALYZED          63     62     1     37     4961     44649                         
    GETRECV1     11/21/2007 8:46:55 AM          TABLE ACCESS     FULL          GML     PO_RECV_HDR     12     TABLE     ANALYZED          64     62     2     136     12098     399234                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          GML     PO_VEND_MST_PK          INDEX (UNIQUE)     ANALYZED     1     65     61     2     0     1     4                         
    GETRECV1     11/21/2007 8:46:55 AM          INDEX     UNIQUE SCAN          GMI     IC_ITEM_MST_TL_PK          INDEX (UNIQUE)     ANALYZED     2     66     1     2     0     1     7                         
    Thanks

  • Equivalent to the Pivot command on Oracle 10g

    Hi,
    I have a requirement where i want change the below statement so it pivots on the day of the week
    select periodid, entrydate, duration
    from period
    where period_id = xxxx
    The above statement will return 7 records for each of the days of the week.
    I want these 7 days to become columns.
    Is there a way I can change this so is it
    select period_id_monday, monday_duration, period_id_tuesday, tuesday_duration,
    period_id_wednesday, wednesday_duration, period_id_thursdayday, thursday_duration,
    period_id_friday, friday_duration
    without having 7 separate sub queries.
    Pivot command in SQL server is only for group functions from what I remember
    Regards
    Stephen

    You could have googled or searched the forums! The method is
    select max(decode(to_char(entrydate, 'fmDAY', 'nls_date_language=english'), 'MONDAY', periodid)) monday_perodid,
           max(decode(to_char(entrydate, 'fmDAY', 'nls_date_language=english'), 'MONDAY', duration)) monday_duration,
    from   perod
    where  period_id = xxxxleaving you to fill in the blanks...
    Edited by: Boneist on 01-Jul-2009 12:01

  • APEX 3.2 -ORACLE 10G - PIVOT QUERY

    Hello, i searched around the forum and i cound't find an answer to this specific matter, although i saw some replies that were close...
    i need to creat a form based on a pivot query. but oracle 10g doesn't support that feature so i hope someone can help me.
    my problem is that the number of columns will be variable. here's an example:
    ORIGINAL TABLE
    NAME     KMS     VEHICLE
    Joe     100     AUDI
    Tom     300     VW
    Mark     150     FORD
    Ann     250     FORD
    Joe     200     VW
    Tom     123     AUDI
    Mark     345     AUDI
    Ann     45     VW
    Joe     6     FORD
    Tom     67     FORD
    Mark     46     VW
    Ann     99     AUDI
    DESIRED RESULT
    Joe     Tom     Mark     Ann     Vehicle
    100     123     345     99     AUDI
    6     67     150     250     FORD
    200     300     46     45     VW
    the new columns will be the values in the old NAME column. BUT these values are variable. today its joe,tom,mark and ann tomorrow it could be silvia, tony,richard,harry , william and jane. this means the usuall replies i saw, using MAX and DECODE will not apply because i never know what values or how many values are in this column. with pivot i can get this done.... how can i do this in oracle 10g? is there a way to creat a ser function Pivot somehow? ideas?
    thanks!
    Mark Pereira
    Edited by: 899716 on Jul 18, 2012 12:02 PM

    This is the Oracle Forms forum. Post your question in the SQL forum.
    Tip: check the latest Oracle Magazine (July/August 2012). There is an article by Tom Kyte about the same question.
    http://www.oracle.com/technetwork/oramag/magazine/home/index.html

  • Oracle 10g Pivot query

    Hi,
    I want to create a view. Sales amounts, countries and products will be showed in this view.
    Report result will be like below:
    Products
    Countries Sales_Amount
    TV Ipad Iphone Netbook Notebook EbookReader
    England 1000 1200 1400 3000 5000 200
    Germany 800 1000 1300 2800 6000 400
    France 1100 1100 1500 2400 3000 500
    Number of products are not limited. New prodcuts can be added by the time.
    Customer is using Oracle 10g. So I can not use pivot function which cames with Oracle 11g.
    If the number of products is limited, I can write sql by decode operators.
    But I can not find how to implement pivot function in Oracle 10g with unlimited column values.
    Do you have any comment?
    Thanks,Regards

    From the SQL and PL/SQL FAQ:
    "This is not easily possible as the number of columns returned by an SQL must be known before any data is fetched, it would have to be done dynamically.
    See these threads:
    Franks pivoting, static and dynamic
    Dynamic Columns Pipelined"
    SQL and PL/SQL FAQ

Maybe you are looking for

  • EFI update on 24" White iMac.

    the installation was successful but the computer wakes up from sleep and turns it on automatically. What can I do?

  • Right way to get Mobile's TIME ?? problem...

    Hi, I need to display the mobiles system time in my application. I'm getting the time using System.currentTimeMillis() and then using it in the Calendar class to get individual values of hours, minutes, secs, etc... But whats happening is the time I'

  • Weak references

    Why is it that SoftReference overrides the get() method in the Reference class. I can undertand that phantom references must do this as they always return null from get() but why is it so with soft refs? Andrew

  • Using an iTunes song as a ringtone on iPhone

    I had my iPhone set up to use a tune from iTunes as my ringtone.  That function has dissappeared and all I have are the Apple ringtones.  I presume this happened when I upgraded the IOS. Any ideas as to how I can restore my tune as a ringtone? Thank

  • How to create checkbox group and table dynamically?

    HI All How to create checkbox group and table dynamically? Regards Ravi