Can we write SQ01 query on bkpf vs faglflexa...

Hi All,
Is it possible to write an infoset to join two tables BKPF and FAGLFLEXA..
I have written an infoset for the same but when i execute the query it's not showing any data in the out put list..
can any one help me how to make this possible..
Thanks in advance,
Viswa

Hi Viswa
did you get solution. i am getting same problem aswell. when i check faglflexa i have data. but, i dont see any data using SAP infosetQuery. below is the message details.
can anyone help me on this
No data was selected
Message no. AQ260
Diagnosis
When executing a query on the selection screen, no data was found for the criteria you entered. Therefore, no list could be generated.
Regards
Sri

Similar Messages

  • Crystal Report XI: Can you write your query in SQL instead of using the GUI

    Hello
      In crystal report version XI, can you write your query in sqlplus and then use the crystal report designer to build your report instead of using the GUI . I would like to be able to go database and show sql query and open that query and make changes directly there, is that possible on this version, if yes is there a setting somewhere? Please let me know.
    Thank you
    alpha

    Moved to Database forum.
    No you can no longer modify the SQL directly. Use a Command Object to enter the SQL directly.
    Thank you
    Don

  • CAn we write a query like this

    CAn we write a query like this?
    If not how can this be changed?
    select col1,col2,col3.col4
    from table 1
    where col1,col2 in(select col1,col2 from table2)

    Or it may be identical:
    SQL> CREATE TABLE t1 (c INT NOT NULL);
    Table created.
    SQL> CREATE TABLE t2 (c INT NOT NULL);
    Table created.
    SQL> INSERT ALL
      2  INTO t1 VALUES (rn)       
      3  INTO t2 VALUES (rn)
      4  SELECT rownum AS rn FROM user_tables WHERE rownum <= 15;
    30 rows created.
    SQL> BEGIN                                       
      2  DBMS_STATS.GATHER_TABLE_STATS(user,'T1');
      3  DBMS_STATS.GATHER_TABLE_STATS(user,'T2');
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM t1
      2  WHERE  EXISTS
      3         ( SELECT 1 FROM t2 WHERE c = t1.c )
      4 
    SQL> @xplan
    | Id  | Operation            |  Name       | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT     |             |    15 |    90 |     5 |
    |*  1 |  HASH JOIN SEMI      |             |    15 |    90 |     5 |
    |   2 |   TABLE ACCESS FULL  | T1          |    15 |    45 |     2 |
    |   3 |   TABLE ACCESS FULL  | T2          |    15 |    45 |     2 |
    Predicate Information (identified by operation id):
       1 - access("T2"."C"="T1"."C")
    SQL> SELECT * FROM t1
      2  WHERE  c IN
      3         ( SELECT c FROM t2 )
      4 
    SQL> @xplan
    | Id  | Operation            |  Name       | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT     |             |    15 |    90 |     5 |
    |*  1 |  HASH JOIN SEMI      |             |    15 |    90 |     5 |
    |   2 |   TABLE ACCESS FULL  | T1          |    15 |    45 |     2 |
    |   3 |   TABLE ACCESS FULL  | T2          |    15 |    45 |     2 |
    Predicate Information (identified by operation id):
       1 - access("T1"."C"="T2"."C")

  • Can we write select query regardless of case sensitivity?

    Hello Everyone,
    I have written one function module. And in this FM i am using one import parameter which has Data element and domain as type. In that i have checked Upper/Lower case checkbox, to retain case of the data in table. But when firing query to database i have to supply same case as it is stored in table.
    so, can i ignore the case of the parameter in select query and can i fire the query regardless of the case of the where conition??
    Thanks in Advance,
    Bhavik

    Hi Bhavik,
    You can do this without adding a column to the table.
    Just Fetch all the data in one internal table then loop that table inside that loop check whether that field contains that string or not. For this you use CP operator, that checks for string irrespective of the case. This can perform wild serach also. The following code may help you,
        SELECT * FROM /cpd/d_mp_hdr_s INTO TABLE it_mast_hdr_desc1.
        LOOP AT it_mast_hdr_desc1 INTO wa_mast_hdr_desc.
          IF wa_mast_hdr_desc-text CP lv_mp_text.
            APPEND wa_mast_hdr_desc TO it_mast_hdr_desc.
            CLEAR wa_mast_hdr_desc.
          ENDIF.
        ENDLOOP.
    Here both the internal table and the work area are of type /cpd/d_mp_hdr_s.
    Hope this helps you.
    With Regards,
    Ajeet Pratap Singh

  • How can I write a query for this table?

    Dear friends
    I have a table with the following structur and data
    ID Name Value
    1 book 100
    2 book 200
    3 car 25
    4 car 35
    5 book 300
    now I would like write a query with following out put
    Name value
    book 100 , 200 , 300
    car 25 , 35
    (with , Separator) (my oracle version is 10g)
    thanks

    Try this,
    SQL> WITH t AS(SELECT 'book' NAME, 100 VALUE FROM dual UNION ALL
      2  SELECT 'book', 200 FROM dual UNION ALL
      3  SELECT 'car', 25 FROM dual UNION ALL
      4  SELECT 'car', 35 FROM dual UNION ALL
      5  SELECT 'book', 300 FROM dual)
      6      SELECT NAME, LTRIM (MAX (SYS_CONNECT_BY_PATH (VALUE, ',')), ',') VALUE
      7        FROM (SELECT NAME, VALUE, ROW_NUMBER () OVER (PARTITION BY NAME ORDER BY VALUE) rn FROM t)
      8  START WITH rn = 1
      9  CONNECT BY PRIOR rn + 1 = rn
    10             AND PRIOR NAME = NAME
    11    GROUP BY NAME;
    NAME VALUE
    book 100,200,300
    car  25,35
    2 rows selected.
    SQL> G.

  • How can I write this query

    Customer Trans          Transaction     Invoice
    Code     Date Type      Amount
    A001     01-JAN-2004     invoice      1000
    A001     01-FEB-2004      Receipt      -1500
    A001     01-MAR-2004     invoice          2000
    A001     01-APR-2002     invoice          2500
    OUTPUT wanted to be...
    Customer Trans     Transaction     Invoice          
    Code     Date Type      Amount     Balance
    A001 01-JAN-2004 invoice 1000          1000
    A001     01-FEB-2004 receipt -1500          500     
    A001     01-MAR-2004 invoice     2000          2500
    A001     01-APR-2002 invoice     2500          5000
    Hi All,
    Please look into the above data, If analytic function LAG(),CASE expression are possible to locate the cursor position in the single query, then any one can help me out about it. I tried but could not.
    Regards,
    Neel.

    You can do this with the SUM analytic function. Taking the emp table, for example,
      1  select ename, sal, SUM(sal) OVER (order by empno)
      2    from emp
      3*  order by empno
    SQL> /
    ENAME                                 SAL SUM(SAL)OVER(ORDERBYEMPNO)
    SMITH                                 800                        800
    ALLEN                                1600                       2400
    WARD                                 1250                       3650
    JONES                                2975                       6625
    MARTIN                               1250                       7875
    BLAKE                                2850                      10725
    CLARK                                2450                      13175
    SCOTT                                3000                      16175
    KING                                 5000                      21175
    TURNER                               1500                      22675
    ADAMS                                1100                      23775
    JAMES                                 950                      24725
    FORD                                 3000                      27725
    MILLER                               1300                      29025
    14 rows selected.Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Can I write this query in another way (prefferably in optimized manner)

    My database version._
    [oracle@localhost ~]$ uname -a
    Linux localhost.localdomain 2.6.18-194.17.1.0.1.el5 #1 SMP Wed Sep 29 15:40:03 EDT 2010 i686 i686 i386 GNU/Linux
    [oracle@localhost ~]$ sqlplus / as sysdba
    SQL*Plus: Release 11.2.0.2.0 Production on Fri Aug 12 04:44:21 2011
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> SELECT * FROM v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    SQL>
    Introduction to data and logic._
    I have on table called inv_leg_dummy. The main columns to consider is arrival_airport and departure_airport. Say a flight starts from kolkata (KOL) -> Goes to Dellhi (DEL) -> Goes to Hongkong (HKG) -> Goes to Tiwan (TPE). So in total KOL -> DEL -> HKG -> TPE
    Data will be like:
    Arrival Airport         Departure Airport
    HKG                       TPE
    KOL                       DEL
    DEL                       HKGPlease note that the order is not as expected, that means the flight starts from kolkata can not be determined straight way from the arrangment or any kind of flag.
    The main logic is, I first take Arrival Airport HKG and see if any Departure Airport exists as HKG, then I take the next KOL and see if any Departure Airport exists as KOL. You can notice KOL is only present as arrival airport, So, This is the first leg of the flight journey. By the same logic, I can determine next leg, that is DEL (because flight goes from KOL to DEL)...
    I need output like :
    ARRIVAL_AIRPORT     DEPARTURE_AIRPORT     SEQ
    HKG                  TPE              1
    DEL                  HKG              2
    KOL                  DEL              3
                      KOL              4So, The starting point KOL has heighest sequence (arrival is null), then KOL to DEL, DEL to HKG and finally HKG to TPE (sequence 1). The sequence may look like reverse order.
    Create Table and Insert Scripts._
    CREATE TABLE inv_leg_dummy
      carrier              VARCHAR2(3) not null,
      flt_num              VARCHAR2(4) not null,
      flt_num_suffix       VARCHAR2(1) default ' ' not null,
      flt_date             DATE not null,
      arrival_airport              VARCHAR2(5),
      departure_airport              VARCHAR2(5) not null
    alter table inv_leg_dummy
      add constraint XPKINV_LEG primary key (carrier,flt_num,flt_num_suffix,flt_date,departure_airport);
    TRUNCATE table inv_leg_dummy; 
    INSERT INTO inv_leg_dummy VALUES ('KA',1,' ',to_date('05/23/2011','mm/dd/rrrr'),'HKG','TPE');
    INSERT INTO inv_leg_dummy VALUES ('KA',1,' ',to_date('05/23/2011','mm/dd/rrrr'),'KOL','DEL');
    INSERT INTO inv_leg_dummy VALUES ('KA',1,' ',to_date('05/23/2011','mm/dd/rrrr'),'DEL','HKG');
    INSERT INTO inv_leg_dummy VALUES ('CX',1,' ',to_date('05/22/2011','mm/dd/rrrr'),'HKG','BNE');
    INSERT INTO inv_leg_dummy VALUES ('CX',1,' ',to_date('05/22/2011','mm/dd/rrrr'),'BNE','CNS');
    Now, it time to show you, What I have done!_
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT Carrier,
      2         Flt_Num,
      3         Flt_Date,
      4         Flt_num_Suffix,
      5         arrival_airport,
      6         departure_airport,
      7         RANK() OVER(partition by Carrier, Flt_Num, Flt_Date, Flt_num_Suffix ORDER BY Carrier, Flt_Num, Flt_Date, Flt_num_Suffix, SEQ ASC NULLS LAST) SEQ,
      8         /* Fetching Maximum leg Seq No excluding Dummy Leg*/
      9         max(seq) over(partition by carrier, flt_num, flt_date, flt_num_suffix order by carrier, flt_num, flt_date, flt_num_suffix) max_seq
    10    FROM (SELECT k.Carrier,
    11                 k.Flt_Num,
    12                 k.Flt_Date,
    13                 k.Flt_num_Suffix,
    14                 k.departure_airport,
    15                 k.arrival_airport,
    16                 level seq
    17            FROM (SELECT
    18                   l.Carrier,
    19                   l.Flt_Num,
    20                   l.Flt_Date,
    21                   l.Flt_num_Suffix,
    22                   l.departure_airport,
    23                   l.arrival_airport
    24                    FROM inv_leg_dummy l) k
    25           START WITH k.departure_airport = case when
    26           (select count(*)
    27                         FROM inv_leg_dummy ifl
    28                        WHERE ifl.arrival_airport = k.departure_airport
    29                          AND ifl.flt_num = k.flt_num
    30                          AND ifl.carrier = k.carrier
    31                          AND ifl.flt_num_suffix = k.Flt_num_Suffix) = 0 then k.departure_airport end
    32          CONNECT BY prior k.arrival_airport = k.departure_airport
    33                 AND prior k.carrier = k.carrier
    34                 AND prior k.flt_num = k.flt_num
    35                 AND prior TRUNC(k.flt_date) =
    36                                                TRUNC(k.flt_date)
    37          UNION ALL
    38          /* Fetching Dummy Last Leg Information for Leg_Seq No*/
    39          SELECT ofl.Carrier,
    40                 ofl.Flt_Num,
    41                 ofl.Flt_Date,
    42                 ofl.Flt_num_Suffix,
    43                 ofl.arrival_airport as departure_airport,
    44                 NULL arrival_airport,
    45                 NULL seq
    46            FROM inv_leg_dummy ofl
    47           where NOT EXISTS (SELECT 1
    48                    FROM inv_leg_dummy ifl
    49                   WHERE ofl.arrival_airport = ifl.departure_airport
    50                     AND ifl.flt_num = ofl.flt_num
    51                     AND ifl.carrier = ofl.carrier
    52                     AND ifl.flt_num_suffix =ofl.Flt_num_Suffix))
    53*  ORDER BY 1, 2, 3, 4,7
    SQL> /
    CAR FLT_ FLT_DATE  F ARRIV DEPAR        SEQ    MAX_SEQ
    CX  1    22-MAY-11   BNE   CNS            1          2
    CX  1    22-MAY-11   HKG   BNE            2          2
    CX  1    22-MAY-11         HKG            3          2
    KA  1    23-MAY-11   HKG   TPE            1          3
    KA  1    23-MAY-11   DEL   HKG            2          3
    KA  1    23-MAY-11   KOL   DEL            3          3
    KA  1    23-MAY-11         KOL            4          3
    7 rows selected.
    SQL> The code is giving the right output, But I feel, I have done it in a hard way. Is there any easier/optimized approach to solve the problem ?

    Hello
    I thought I'd run run all 3 methods twice with autotrace to get an overview of the execution plans and basic performance metrics. The results are interesting.
    OPs method
    SQL> set autot on
    SQL> SELECT Carrier,
      2           Flt_Num,
      3           Flt_Date,
      4           Flt_num_Suffix,
      5           arrival_airport,
      6           departure_airport,
      7           RANK() OVER(partition by Carrier, Flt_Num, Flt_Date, Flt_num_Suffix ORDER BY Carrier, Flt_Num,
    53   ORDER BY 1, 2, 3, 4,7
    54  /
    CAR FLT_ FLT_DATE  F ARRIV DEPAR        SEQ    MAX_SEQ
    CX  1    22-MAY-11   BNE   CNS            1          2
    CX  1    22-MAY-11   HKG   BNE            2          2
    CX  1    22-MAY-11         HKG            3          2
    KA  1    23-MAY-11   HKG   TPE            1          3
    KA  1    23-MAY-11   DEL   HKG            2          3
    KA  1    23-MAY-11   KOL   DEL            3          3
    KA  1    23-MAY-11         KOL            4          3
    7 rows selected.
    Execution Plan
    Plan hash value: 3680289985
    | Id  | Operation                         | Name          |
    |   0 | SELECT STATEMENT                  |               |
    |   1 |  WINDOW SORT                      |               |
    |   2 |   VIEW                            |               |
    |   3 |    UNION-ALL                      |               |
    |*  4 |     CONNECT BY WITH FILTERING     |               |
    |*  5 |      FILTER                       |               |
    |*  6 |       TABLE ACCESS FULL           | INV_LEG_DUMMY |
    |   7 |       SORT AGGREGATE              |               |
    |*  8 |        TABLE ACCESS BY INDEX ROWID| INV_LEG_DUMMY |
    |*  9 |         INDEX RANGE SCAN          | XPKINV_LEG    |
    |  10 |      NESTED LOOPS                 |               |
    |  11 |       CONNECT BY PUMP             |               |
    |  12 |       TABLE ACCESS BY INDEX ROWID | INV_LEG_DUMMY |
    |* 13 |        INDEX RANGE SCAN           | XPKINV_LEG    |
    |* 14 |     FILTER                        |               |
    |  15 |      TABLE ACCESS FULL            | INV_LEG_DUMMY |
    |* 16 |      INDEX RANGE SCAN             | XPKINV_LEG    |
    Predicate Information (identified by operation id):
       4 - access("L"."DEPARTURE_AIRPORT"=PRIOR "L"."ARRIVAL_AIRPORT" AND
                  "L"."CARRIER"=PRIOR "L"."CARRIER" AND "L"."FLT_NUM"=PRIOR "L"."FLT
    _NUM"
                  AND INTERNAL_FUNCTION(PRIOR TRUNC(INTERNAL_FUNCTION("L"."FLT_DATE"
    )))=TR
                  UNC(INTERNAL_FUNCTION("L"."FLT_DATE")))
       5 - filter("L"."DEPARTURE_AIRPORT"=CASE  WHEN ( (SELECT COUNT(*)
                  FROM "INV_LEG_DUMMY" "IFL" WHERE "IFL"."FLT_NUM_SUFFIX"=:B1 AND
                  "IFL"."FLT_NUM"=:B2 AND "IFL"."CARRIER"=:B3 AND
                  "IFL"."ARRIVAL_AIRPORT"=:B4)=0) THEN "L"."DEPARTURE_AIRPORT" END )
       6 - access("L"."CARRIER"=PRIOR "L"."CARRIER")
       8 - filter("IFL"."ARRIVAL_AIRPORT"=:B1)
       9 - access("IFL"."CARRIER"=:B1 AND "IFL"."FLT_NUM"=:B2 AND
                  "IFL"."FLT_NUM_SUFFIX"=:B3)
      13 - access("L"."CARRIER"=PRIOR "L"."CARRIER" AND "L"."FLT_NUM"=PRIOR
                  "L"."FLT_NUM" AND "L"."DEPARTURE_AIRPORT"=PRIOR "L"."ARRIVAL_AIRPO
    RT")
           filter("L"."DEPARTURE_AIRPORT"=PRIOR "L"."ARRIVAL_AIRPORT" AND
                  INTERNAL_FUNCTION(PRIOR TRUNC(INTERNAL_FUNCTION("L"."FLT_DATE")))=
    TRUNC(
                  INTERNAL_FUNCTION("L"."FLT_DATE")))
      14 - filter( NOT EXISTS (SELECT 0 FROM "INV_LEG_DUMMY" "IFL" WHERE
                  "IFL"."FLT_NUM_SUFFIX"=:B1 AND "IFL"."FLT_NUM"=:B2 AND
                  "IFL"."CARRIER"=:B3 AND "IFL"."DEPARTURE_AIRPORT"=:B4))
      16 - access("IFL"."CARRIER"=:B1 AND "IFL"."FLT_NUM"=:B2 AND
                  "IFL"."FLT_NUM_SUFFIX"=:B3 AND "IFL"."DEPARTURE_AIRPORT"=:B4)
           filter("IFL"."DEPARTURE_AIRPORT"=:B1)
    Note
       - rule based optimizer used (consider using cbo)
    Statistics
              1  recursive calls
              0  db block gets
             33  consistent gets
              0  physical reads
              0  redo size
            877  bytes sent via SQL*Net to client
            886  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              6  sorts (memory)
              0  sorts (disk)
              7  rows processed
    SQL> /
    CAR FLT_ FLT_DATE  F ARRIV DEPAR        SEQ    MAX_SEQ
    CX  1    22-MAY-11   BNE   CNS            1          2
    CX  1    22-MAY-11   HKG   BNE            2          2
    CX  1    22-MAY-11         HKG            3          2
    KA  1    23-MAY-11   HKG   TPE            1          3
    KA  1    23-MAY-11   DEL   HKG            2          3
    KA  1    23-MAY-11   KOL   DEL            3          3
    KA  1    23-MAY-11         KOL            4          3
    7 rows selected.
    Execution Plan
    Plan hash value: 3680289985
    | Id  | Operation                         | Name          |
    |   0 | SELECT STATEMENT                  |               |
    |   1 |  WINDOW SORT                      |               |
    |   2 |   VIEW                            |               |
    |   3 |    UNION-ALL                      |               |
    |*  4 |     CONNECT BY WITH FILTERING     |               |
    |*  5 |      FILTER                       |               |
    |*  6 |       TABLE ACCESS FULL           | INV_LEG_DUMMY |
    |   7 |       SORT AGGREGATE              |               |
    |*  8 |        TABLE ACCESS BY INDEX ROWID| INV_LEG_DUMMY |
    |*  9 |         INDEX RANGE SCAN          | XPKINV_LEG    |
    |  10 |      NESTED LOOPS                 |               |
    |  11 |       CONNECT BY PUMP             |               |
    |  12 |       TABLE ACCESS BY INDEX ROWID | INV_LEG_DUMMY |
    |* 13 |        INDEX RANGE SCAN           | XPKINV_LEG    |
    |* 14 |     FILTER                        |               |
    |  15 |      TABLE ACCESS FULL            | INV_LEG_DUMMY |
    |* 16 |      INDEX RANGE SCAN             | XPKINV_LEG    |
    Predicate Information (identified by operation id):
       4 - access("L"."DEPARTURE_AIRPORT"=PRIOR "L"."ARRIVAL_AIRPORT" AND
                  "L"."CARRIER"=PRIOR "L"."CARRIER" AND "L"."FLT_NUM"=PRIOR "L"."FLT
    _NUM"
                  AND INTERNAL_FUNCTION(PRIOR TRUNC(INTERNAL_FUNCTION("L"."FLT_DATE"
    )))=TR
                  UNC(INTERNAL_FUNCTION("L"."FLT_DATE")))
       5 - filter("L"."DEPARTURE_AIRPORT"=CASE  WHEN ( (SELECT COUNT(*)
                  FROM "INV_LEG_DUMMY" "IFL" WHERE "IFL"."FLT_NUM_SUFFIX"=:B1 AND
                  "IFL"."FLT_NUM"=:B2 AND "IFL"."CARRIER"=:B3 AND
                  "IFL"."ARRIVAL_AIRPORT"=:B4)=0) THEN "L"."DEPARTURE_AIRPORT" END )
       6 - access("L"."CARRIER"=PRIOR "L"."CARRIER")
       8 - filter("IFL"."ARRIVAL_AIRPORT"=:B1)
       9 - access("IFL"."CARRIER"=:B1 AND "IFL"."FLT_NUM"=:B2 AND
                  "IFL"."FLT_NUM_SUFFIX"=:B3)
      13 - access("L"."CARRIER"=PRIOR "L"."CARRIER" AND "L"."FLT_NUM"=PRIOR
                  "L"."FLT_NUM" AND "L"."DEPARTURE_AIRPORT"=PRIOR "L"."ARRIVAL_AIRPO
    RT")
           filter("L"."DEPARTURE_AIRPORT"=PRIOR "L"."ARRIVAL_AIRPORT" AND
                  INTERNAL_FUNCTION(PRIOR TRUNC(INTERNAL_FUNCTION("L"."FLT_DATE")))=
    TRUNC(
                  INTERNAL_FUNCTION("L"."FLT_DATE")))
      14 - filter( NOT EXISTS (SELECT 0 FROM "INV_LEG_DUMMY" "IFL" WHERE
                  "IFL"."FLT_NUM_SUFFIX"=:B1 AND "IFL"."FLT_NUM"=:B2 AND
                  "IFL"."CARRIER"=:B3 AND "IFL"."DEPARTURE_AIRPORT"=:B4))
      16 - access("IFL"."CARRIER"=:B1 AND "IFL"."FLT_NUM"=:B2 AND
                  "IFL"."FLT_NUM_SUFFIX"=:B3 AND "IFL"."DEPARTURE_AIRPORT"=:B4)
           filter("IFL"."DEPARTURE_AIRPORT"=:B1)
    Note
       - rule based optimizer used (consider using cbo)
    Statistics
              0  recursive calls
              0  db block gets
             33  consistent gets
              0  physical reads
              0  redo size
            877  bytes sent via SQL*Net to client
            886  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              6  sorts (memory)
              0  sorts (disk)
              7  rows processedMy method
    SQL> SELECT
      2      carrier,
      3      flt_num,
      4      flt_num_suffix,
      5      flt_date,
      6      arrival_airport,
      7      departure_airport,
      8      COUNT(*) OVER(PARTITION BY carrier,
      9                                  flt_num
    10                    ) - LEVEL + 1  seq,
    11      COUNT(*) OVER(PARTITION BY carrier,
    12                                  flt_num
    13                    )  - 1        max_seq
    57  /
    CAR FLT_ F FLT_DATE  ARRIV DEPAR        SEQ    MAX_SEQ
    CX  1      22-MAY-11 BNE   CNS            1          2
    CX  1      22-MAY-11 HKG   BNE            2          2
    CX  1      22-MAY-11       HKG            3          2
    KA  1      23-MAY-11 HKG   TPE            1          3
    KA  1      23-MAY-11 DEL   HKG            2          3
    KA  1      23-MAY-11 KOL   DEL            3          3
    KA  1      23-MAY-11       KOL            4          3
    7 rows selected.
    Execution Plan
    Plan hash value: 921778235
    | Id  | Operation                                 | Name          |
    |   0 | SELECT STATEMENT                          |               |
    |   1 |  SORT ORDER BY                            |               |
    |   2 |   WINDOW SORT                             |               |
    |*  3 |    CONNECT BY NO FILTERING WITH START-WITH|               |
    |   4 |     COUNT                                 |               |
    |   5 |      VIEW                                 |               |
    |   6 |       UNION-ALL                           |               |
    |   7 |        TABLE ACCESS FULL                  | INV_LEG_DUMMY |
    |*  8 |        FILTER                             |               |
    |   9 |         TABLE ACCESS FULL                 | INV_LEG_DUMMY |
    |* 10 |         INDEX RANGE SCAN                  | XPKINV_LEG    |
    Predicate Information (identified by operation id):
       3 - access("ARRIVAL_AIRPORT"=PRIOR "DEPARTURE_AIRPORT" AND
                  "CARRIER"=PRIOR "CARRIER" AND "FLT_NUM"=PRIOR "FLT_NUM" AND
                  TRUNC(INTERNAL_FUNCTION("FLT_DATE"))=INTERNAL_FUNCTION(PRIOR
                  TRUNC(INTERNAL_FUNCTION("FLT_DATE"))))
           filter("ARRIVAL_AIRPORT" IS NULL)
       8 - filter( NOT EXISTS (SELECT 0 FROM "INV_LEG_DUMMY" "DL" WHERE
                  "DL"."FLT_NUM"=:B1 AND "DL"."CARRIER"=:B2 AND
                  "DL"."DEPARTURE_AIRPORT"=:B3 AND "DL"."FLT_DATE"=:B4))
      10 - access("DL"."CARRIER"=:B1 AND "DL"."FLT_NUM"=:B2 AND
                  "DL"."FLT_DATE"=:B3 AND "DL"."DEPARTURE_AIRPORT"=:B4)
           filter("DL"."DEPARTURE_AIRPORT"=:B1 AND "DL"."FLT_DATE"=:B2)
    Note
       - rule based optimizer used (consider using cbo)
    Statistics
              1  recursive calls
              0  db block gets
             19  consistent gets
              0  physical reads
              0  redo size
            877  bytes sent via SQL*Net to client
            338  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              4  sorts (memory)
              0  sorts (disk)
              7  rows processed
    SQL> /
    CAR FLT_ F FLT_DATE  ARRIV DEPAR        SEQ    MAX_SEQ
    CX  1      22-MAY-11 BNE   CNS            1          2
    CX  1      22-MAY-11 HKG   BNE            2          2
    CX  1      22-MAY-11       HKG            3          2
    KA  1      23-MAY-11 HKG   TPE            1          3
    KA  1      23-MAY-11 DEL   HKG            2          3
    KA  1      23-MAY-11 KOL   DEL            3          3
    KA  1      23-MAY-11       KOL            4          3
    7 rows selected.
    Execution Plan
    Plan hash value: 921778235
    | Id  | Operation                                 | Name          |
    |   0 | SELECT STATEMENT                          |               |
    |   1 |  SORT ORDER BY                            |               |
    |   2 |   WINDOW SORT                             |               |
    |*  3 |    CONNECT BY NO FILTERING WITH START-WITH|               |
    |   4 |     COUNT                                 |               |
    |   5 |      VIEW                                 |               |
    |   6 |       UNION-ALL                           |               |
    |   7 |        TABLE ACCESS FULL                  | INV_LEG_DUMMY |
    |*  8 |        FILTER                             |               |
    |   9 |         TABLE ACCESS FULL                 | INV_LEG_DUMMY |
    |* 10 |         INDEX RANGE SCAN                  | XPKINV_LEG    |
    Predicate Information (identified by operation id):
       3 - access("ARRIVAL_AIRPORT"=PRIOR "DEPARTURE_AIRPORT" AND
                  "CARRIER"=PRIOR "CARRIER" AND "FLT_NUM"=PRIOR "FLT_NUM" AND
                  TRUNC(INTERNAL_FUNCTION("FLT_DATE"))=INTERNAL_FUNCTION(PRIOR
                  TRUNC(INTERNAL_FUNCTION("FLT_DATE"))))
           filter("ARRIVAL_AIRPORT" IS NULL)
       8 - filter( NOT EXISTS (SELECT 0 FROM "INV_LEG_DUMMY" "DL" WHERE
                  "DL"."FLT_NUM"=:B1 AND "DL"."CARRIER"=:B2 AND
                  "DL"."DEPARTURE_AIRPORT"=:B3 AND "DL"."FLT_DATE"=:B4))
      10 - access("DL"."CARRIER"=:B1 AND "DL"."FLT_NUM"=:B2 AND
                  "DL"."FLT_DATE"=:B3 AND "DL"."DEPARTURE_AIRPORT"=:B4)
           filter("DL"."DEPARTURE_AIRPORT"=:B1 AND "DL"."FLT_DATE"=:B2)
    Note
       - rule based optimizer used (consider using cbo)
    Statistics
              0  recursive calls
              0  db block gets
             19  consistent gets
              0  physical reads
              0  redo size
            877  bytes sent via SQL*Net to client
            338  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              4  sorts (memory)
              0  sorts (disk)
              7  rows processedSalim Chelabi's method
    SQL> WITH t AS
      2       (SELECT     k.*, LEVEL lvl
      3              FROM inv_leg_dummy k
      4        CONNECT BY PRIOR k.arrival_airport = k.departure_airport
      5               AND PRIOR k.flt_date = k.flt_date
      6               AND PRIOR k.carrier = k.carrier
      7               AND PRIOR k.flt_num = k.flt_num)
      8  SELECT   carrier, flt_num, flt_num_suffix, flt_date, arrival_airport,
      9           departure_airport, MAX (lvl) seq,
    10           MAX (MAX (lvl)) OVER (PARTITION BY carrier, flt_num, flt_num_suffix)
    11                                                                        max_seq
    12      FROM t
    13  GROUP BY carrier,
    14           flt_num,
    15           flt_num_suffix,
    16           flt_date,
    17           arrival_airport,
    18           departure_airport
    19  UNION ALL
    20  SELECT   carrier, flt_num, flt_num_suffix, flt_date, NULL,
    21           MAX (arrival_airport), MAX (lvl) + 1 seq, MAX (lvl) max_seq
    22      FROM t
    23  GROUP BY carrier, flt_num, flt_num_suffix, flt_date
    24  ORDER BY 1, 2, 3, seq, arrival_airport NULLS LAST;
    CAR FLT_ F FLT_DATE            ARRIV DEPAR        SEQ    MAX_SEQ
    CX  1      22/05/2011 00:00:00 BNE   CNS            1          2
    CX  1      22/05/2011 00:00:00 HKG   BNE            2          2
    CX  1      22/05/2011 00:00:00       HKG            3          2
    KA  1      23/05/2011 00:00:00 HKG   TPE            1          3
    KA  1      23/05/2011 00:00:00 DEL   HKG            2          3
    KA  1      23/05/2011 00:00:00 KOL   DEL            3          3
    KA  1      23/05/2011 00:00:00       KOL            4          3
    7 rows selected.
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 2360206974
    | Id  | Operation                      | Name                        |
    |   0 | SELECT STATEMENT               |                             |
    |   1 |  TEMP TABLE TRANSFORMATION     |                             |
    |   2 |   LOAD AS SELECT               |                             |
    |*  3 |    CONNECT BY WITHOUT FILTERING|                             |
    |   4 |     TABLE ACCESS FULL          | INV_LEG_DUMMY               |
    |   5 |   SORT ORDER BY                |                             |
    |   6 |    UNION-ALL                   |                             |
    |   7 |     WINDOW BUFFER              |                             |
    |   8 |      SORT GROUP BY             |                             |
    |   9 |       VIEW                     |                             |
    |  10 |        TABLE ACCESS FULL       | SYS_TEMP_0FD9FE280_59EF9B75 |
    |  11 |     SORT GROUP BY              |                             |
    |  12 |      VIEW                      |                             |
    |  13 |       TABLE ACCESS FULL        | SYS_TEMP_0FD9FE280_59EF9B75 |
    Predicate Information (identified by operation id):
       3 - access("K"."DEPARTURE_AIRPORT"=PRIOR "K"."ARRIVAL_AIRPORT" AND
                  "K"."FLT_DATE"=PRIOR "K"."FLT_DATE" AND "K"."CARRIER"=PRIOR
                  "K"."CARRIER" AND "K"."FLT_NUM"=PRIOR "K"."FLT_NUM")
    Note
       - rule based optimizer used (consider using cbo)
    Statistics
             57  recursive calls
             10  db block gets
             25  consistent gets
              1  physical reads
           1556  redo size
            877  bytes sent via SQL*Net to client
            338  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              5  sorts (memory)
              0  sorts (disk)
              7  rows processed
    SQL> /
    CAR FLT_ F FLT_DATE            ARRIV DEPAR        SEQ    MAX_SEQ
    CX  1      22/05/2011 00:00:00 BNE   CNS            1          2
    CX  1      22/05/2011 00:00:00 HKG   BNE            2          2
    CX  1      22/05/2011 00:00:00       HKG            3          2
    KA  1      23/05/2011 00:00:00 HKG   TPE            1          3
    KA  1      23/05/2011 00:00:00 DEL   HKG            2          3
    KA  1      23/05/2011 00:00:00 KOL   DEL            3          3
    KA  1      23/05/2011 00:00:00       KOL            4          3
    7 rows selected.
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 4065363664
    | Id  | Operation                      | Name                        |
    |   0 | SELECT STATEMENT               |                             |
    |   1 |  TEMP TABLE TRANSFORMATION     |                             |
    |   2 |   LOAD AS SELECT               |                             |
    |*  3 |    CONNECT BY WITHOUT FILTERING|                             |
    |   4 |     TABLE ACCESS FULL          | INV_LEG_DUMMY               |
    |   5 |   SORT ORDER BY                |                             |
    |   6 |    UNION-ALL                   |                             |
    |   7 |     WINDOW BUFFER              |                             |
    |   8 |      SORT GROUP BY             |                             |
    |   9 |       VIEW                     |                             |
    |  10 |        TABLE ACCESS FULL       | SYS_TEMP_0FD9FE281_59EF9B75 |
    |  11 |     SORT GROUP BY              |                             |
    |  12 |      VIEW                      |                             |
    |  13 |       TABLE ACCESS FULL        | SYS_TEMP_0FD9FE281_59EF9B75 |
    Predicate Information (identified by operation id):
       3 - access("K"."DEPARTURE_AIRPORT"=PRIOR "K"."ARRIVAL_AIRPORT" AND
                  "K"."FLT_DATE"=PRIOR "K"."FLT_DATE" AND "K"."CARRIER"=PRIOR
                  "K"."CARRIER" AND "K"."FLT_NUM"=PRIOR "K"."FLT_NUM")
    Note
       - rule based optimizer used (consider using cbo)
    Statistics
              2  recursive calls
              8  db block gets
             15  consistent gets
              1  physical reads
            604  redo size
            877  bytes sent via SQL*Net to client
            338  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              5  sorts (memory)
              0  sorts (disk)
              7  rows processed
    SQL> Personally I think Salim's method seems very suiccinct and I had expected there would be more of a difference in terms of performance metrics between it and my attempt but it appears there's not much between the two - although Salim's method is generating redo as a result of the temp table through the subquery factoring. I'd be interested to see the results of a full trace between them.
    Either way though, there are two alternatives which seem a fair bit more optimal than the original SQL so it's quids in I guess! :-)
    David
    Edited by: Bravid on Aug 12, 2011 3:24 PM
    Edited by: Bravid on Aug 12, 2011 3:27 PM
    Updated the comparison with Salims additional column

  • How can i write sql query for this result ?

    Hello Dear,
    Here is the script first.
    CREATE TABLE ACC_TEST(
    AD_ID NUMBER,
    AD_NAME VARCHAR2(50),
    AD_SPM_ID NUMBER);
    /data are
    Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (136,'Saleh Ahmed',129);
    Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (142,'Hamidur Rahman',136);
    Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (124,'Jasim Uddin',null);
    INSERT INTO ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) VALUES (129,'Sazib',124);I Need The Following Result When I Pass A Value Of Ad_Id. For Example I Pass 142 Then Result Should Be
    Select Ad_Id,Ad_Name
    From..
    where ad_id=142
    Ad_Id   Ad_Name
    136     Saleh Ahmed
    129     Sazib
    124     Jasim Uddin
    If I Pass Ad_Id=136 Then Result Should Be
    Ad_Id   Ad_Name
    129     Sazib
    124     Jasim Uddin
    If I Pass Ad_Id=129 Then Result Should Be
    Ad_Id   Ad_Name
    124     Jasim Uddin Database 10G XE
    Any help will be helpful

    Hi,
    HamidHelal wrote:
    WoW ! you acutely got my point. How did you understand that ? lLuck guess. Guessing is usually not the best way to solve problems. It's usually faster and more reliable to say exactly what you want, as well as give an example.
    ittle bit more i want to know, if i want to restrict the output not more then 2, what would be sql ?Now you're not even giviing an example!
    Maybe you want something like this:
    SELECT     ad_id
    ,     ad_name
    FROM     acc_test
    WHERE     LEVEL     BETWEEN 2 AND 3          -- Changed
    START WITH     ad_id     = :target_ad_id
    CONNECT BY     ad_id     = PRIOR ad_spm_id
    ;which will show jsut the parent and the grandparent of the given row.
    I do work with forms developer very much. Sql knowledge is as oracle sql book(cerfitication 9i). But this type of sql isn't available there.
    where can i learn this type of sql ? Different sql then ordinary ?Certification is a different topic entirely.
    There are books and web sites dealing with more advanced techniques. Sorry, I don't know any well enough to recommend them. Some authors (such as Tom Kyte) are consistently good.
    Here are a couple of sites that explain CONNECT BY queries:
    http://www.adp-gmbh.ch/ora/sql/connect_by.html
    http://www.oradev.com/connect_by.jsp

  • How can I write a query for this?

    I have a table as below ,
    room.........date.............inventory
    A..............01/01.................5
    A..............01/02.................5
    A..............01/03.................5
    A..............01/05.................5
    A..............01/06.................5
    A..............01/07.................8
    I want the output as below
    room.....begin_date........end_date......inventory
    A............01/01.................01/03..........5
    A............01/05.................01/06..........5
    A............01/07.................01/07..........8
    Is there any suggestion?
    Thanks
    null

    with x as
    (select 'A' room, to_date ('01/01/2007', 'mm/dd/yyyy') d, 5 i from dual union all
    select 'A' room, to_date ('01/02/2007', 'mm/dd/yyyy') d, 5 i from dual union all
    select 'A' room, to_date ('01/03/2007', 'mm/dd/yyyy') d, 7 i from dual union all
    select 'A' room, to_date ('01/04/2007', 'mm/dd/yyyy') d, 7 i from dual union all
    select 'A' room, to_date ('01/05/2007', 'mm/dd/yyyy') d, 5 i from dual union all
    select 'A' room, to_date ('01/06/2007', 'mm/dd/yyyy') d, 5 i from dual
    select min (d)
         , max (d)
         , min (i)
      from (
    select room
         , d
         , i
         , max (g) over (order by d) mg
      from
    (select room
         , d
         , i
         , case when lead (i) over (partition by grp order by d) = i
           then rownum
           end  g
    from (
    select room
    , d
    , i
    , d - rownum grp
    from x
    order by d
    group by mg

  • How can I write this query In parameterize form so That I can prevent sql Injection

    String strQry = "INSERT INTO tblVoucherType (VhrTypeCode,moduleCode,transCCode,"
    + "voucherType,OrderNumber,active,AccountId) "
    + " values('" + txtVhrCode.Text + "','" + ddlModule.SelectedValue.ToString() + "',"
    + "'" + ddlTrans.SelectedValue.ToString() + "','" + txtVhrName.Text + "','" + btnRadio.SelectedValue + "'"
    + ", '" + status.Checked + "', '" + txtAccount.Text + "')";

    Basically it will look like:
    String strQry = "INSERT INTO tblVoucherType (VhrTypeCode,moduleCode,transCCode, ...)"
    + " values(@VhrCode, @moduleCode, @transCCode, ....)";
    sqlCommand.Parameters.AddWithValue("@VhrCode", txtVhrCode.Text );
    sqlCommand.Parameters.AddWithValue("@moduleCode", ddlModule.SelectedValue.ToString() );
    sqlCommand.Parameters.AddWithValue("@transCCode", ddlTrans.SelectedValue.ToString() );
    .. and so on
    sqlCommand.ExecuteNonQuery();
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How can i write the query for the below output

    Hi,
    I need this kind of output for my report.Please suggest me asap.It's urgent.
    Item Description category subinvcode A B C D....................(All Subinventories)
    1 AAAA FFF 5 8 (Quantity Values for the corresponding subinventories)
    Plz help.

    I still don't have a clue what you're going on about, but here's an example of pivoting that I've knocked up based on your scatty bit of data which may give some hint to you as to what to do....
    SQL> create table inventory as
      2  select 1 as item_id, '0016K8731' as item_desc from dual union
      3  select 2, '0014R0181' from dual;
    Table created.
    SQL>
    SQL> create table sub_inventory as
      2  select 1 as item_id, 'FG_IBM' as sub_item_id, 5 as quantity from dual union
      3  select 1, 'FG_HUN', 4 from dual union
      4  select 1, 'FG_PSA', 12 from dual union
      5  select 2, 'FG_IBM', 1 from dual union
      6  select 2, 'FG_HUN', 17 from dual union
      7  select 2, 'FG_PSA', 3 from dual;
    Table created.
    SQL>
    SQL> select item_desc, max(fg_ibm) as fg_ibm, max(fg_hun) as fg_hun, max(fg_psa) as fg_psa
      2  from (
      3    select i.item_desc,
      4           decode(s.sub_item_id, 'FG_IBM', quantity, null) as fg_ibm,
      5           decode(s.sub_item_id, 'FG_HUN', quantity, null) as fg_hun,
      6           decode(s.sub_item_id, 'FG_PSA', quantity, null) as fg_psa
      7    from inventory i, sub_inventory s
      8    where s.item_id = i.item_id
      9    )
    10  group by item_desc
    11  /
    ITEM_DESC     FG_IBM     FG_HUN     FG_PSA
    0014R0181          1         17          3
    0016K8731          5          4         12
    SQL>

  • Can i use Sub Query Factoring Here ?

    Hi;
    SQL>SELECT * FROM V$VERSION;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionSQL
    select /*+ PARALLEL(det, 4) */ '12062' snapshot_id,det.journal_entry_line_id, det.accounting_date,det.company_code,det.account_number,
    det.transaction_id, det.transaction_id_type, det.amount,det.currency_code,det.debit_or_credit,det.category,det.subcategory,det.reference1,det.reference1_type,
    det.reference2,det.reference2_type,det.gl_batch_id,det.marketplace_id,det.cost_center,det.gl_product_line,det.location,det.project,det.sales_channel,
    det.created_by,det.creation_date,det.last_updated_by,det.last_updated_date,agg.age,last_day(to_date('04/21/2010','MM/DD/YYYY')) snapshot_day
    from
    select company_code, account_number, transaction_id,
    decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type) transaction_id_type,
    (last_day(to_date('04/21/2010','MM/DD/YYYY')) - min(z.accounting_date) ) age,sum(z.amount)
    from
         select /*+ PARALLEL(use, 2) */    company_code,substr(account_number, 1, 5) account_number,transaction_id,
         decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type) transaction_id_type,use.amount,use.accounting_date
         from financials.unbalanced_subledger_entries use
         where use.accounting_date >= to_date('04/21/2010','MM/DD/YYYY')
         and use.accounting_date < to_date('04/21/2010','MM/DD/YYYY') + 1
    UNION ALL
         select /*+ PARALLEL(se, 2) */  company_code, substr(se.account_number, 1, 5) account_number,transaction_id,
         decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type) transaction_id_type,se.amount,se.accounting_date
         from financials.temp2_sl_snapshot_entries se,financials.account_numbers an
         where se.account_number = an.account_number
         and an.subledger_type in ('C', 'AC')
    ) z
    group by company_code,account_number,transaction_id,decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type)
    having abs(sum(z.amount)) >= 0.01
    ) agg,
         select /*+ PARALLEL(det, 2) */ det.journal_entry_line_id,  det.accounting_date, det.company_code, det.account_number, det.transaction_id,  decode(det.transaction_id_type, 'CollectionID', 'SettlementGroupID', det.transaction_id_type) transaction_id_type,
         det.amount, det.currency_code, det.debit_or_credit, det.category, det.subcategory, det.reference1, det.reference1_type, det.reference2, det.reference2_type,
         det.gl_batch_id, det.marketplace_id, det.cost_center, det.gl_product_line, det.location, det.project, det.sales_channel, det.created_by, det.creation_date,
         det.last_updated_by, det.last_updated_date
         from financials.unbalanced_subledger_entries det
         where accounting_date >= to_date('04/21/2010','MM/DD/YYYY')
         and accounting_date < to_date('04/21/2010','MM/DD/YYYY') + 1
    UNION ALL
    select /*+ PARALLEL(det, 2) */  det.journal_entry_line_id, det.accounting_date, det.company_code, det.account_number, det.transaction_id,
    decode(det.transaction_id_type, 'CollectionID', 'SettlementGroupID', det.transaction_id_type) transaction_id_type,  det.amount, det.currency_code,
    det.debit_or_credit, det.category, det.subcategory, det.reference1, det.reference1_type, det.reference2, det.reference2_type, det.gl_batch_id, det.marketplace_id,
    det.cost_center, det.gl_product_line, det.location, det.project, det.sales_channel, det.created_by, det.creation_date, det.last_updated_by, det.last_updated_date
    from financials.temp2_sl_snapshot_entries det,financials.account_numbers an
    where det.account_number = an.account_number
    and an.subledger_type in ('C', 'AC')
    ) det
                       where agg.company_code = det.company_code
                       and agg.account_number = substr(det.account_number, 1, 5)
                       and agg.transaction_id = det.transaction_id
                       and agg.transaction_id_type = det.transaction_id_type
    /Execution Plan
    | Id  | Operation                          | Name                         | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT                   |                              |    12M|  8012M|       |   541K  (1)| 01:48:21 |        |      |            |
    |   1 |  PX COORDINATOR                    |                              |       |       |       |            |          |        |      |            |
    |   2 |   PX SEND QC (RANDOM)              | :TQ10005                     |    12M|  8012M|       |   541K  (1)| 01:48:21 |  Q1,05 | P->S | QC (RAND)  |
    |*  3 |    HASH JOIN BUFFERED              |                              |    12M|  8012M|  1098M|   541K  (1)| 01:48:21 |  Q1,05 | PCWP |            |
    |   4 |     PX RECEIVE                     |                              |    35M|  3992M|       |   166K  (2)| 00:33:16 |  Q1,05 | PCWP |            |
    |   5 |      PX SEND HASH                  | :TQ10003                     |    35M|  3992M|       |   166K  (2)| 00:33:16 |  Q1,03 | P->P | HASH       |
    |   6 |       VIEW                         |                              |    35M|  3992M|       |   166K  (2)| 00:33:16 |  Q1,03 | PCWP |            |
    |*  7 |        FILTER                      |                              |       |       |       |            |          |  Q1,03 | PCWC |            |
    |   8 |         HASH GROUP BY              |                              |    35M|  4528M|       |   166K  (2)| 00:33:16 |  Q1,03 | PCWP |            |
    |   9 |          PX RECEIVE                |                              |    35M|  4528M|       |   166K  (2)| 00:33:16 |  Q1,03 | PCWP |            |
    |  10 |           PX SEND HASH             | :TQ10001                     |    35M|  4528M|       |   166K  (2)| 00:33:16 |  Q1,01 | P->P | HASH       |
    |  11 |            HASH GROUP BY           |                              |    35M|  4528M|       |   166K  (2)| 00:33:16 |  Q1,01 | PCWP |            |
    |  12 |             VIEW                   |                              |    35M|  4528M|       |   164K  (1)| 00:33:00 |  Q1,01 | PCWP |            |
    |  13 |              UNION-ALL             |                              |       |       |       |            |          |  Q1,01 | PCWP |            |
    |  14 |               PX BLOCK ITERATOR    |                              |    11 |   539 |       |  1845   (1)| 00:00:23 |  Q1,01 | PCWC |            |
    |* 15 |                TABLE ACCESS FULL   | UNBALANCED_SUBLEDGER_ENTRIES |    11 |   539 |       |  1845   (1)| 00:00:23 |  Q1,01 | PCWP |            |
    |* 16 |               HASH JOIN            |                              |    35M|  2012M|       |   163K  (1)| 00:32:37 |  Q1,01 | PCWP |            |
    |  17 |                BUFFER SORT         |                              |       |       |       |            |          |  Q1,01 | PCWC |            |
    |  18 |                 PX RECEIVE         |                              |    21 |   210 |       |     2   (0)| 00:00:01 |  Q1,01 | PCWP |            |
    |  19 |                  PX SEND BROADCAST | :TQ10000                     |    21 |   210 |       |     2   (0)| 00:00:01 |        | S->P | BROADCAST  |
    |* 20 |                   TABLE ACCESS FULL| ACCOUNT_NUMBERS              |    21 |   210 |       |     2   (0)| 00:00:01 |        |      |            |
    |  21 |                PX BLOCK ITERATOR   |                              |    56M|  2701M|       |   162K  (1)| 00:32:35 |  Q1,01 | PCWC |            |
    |  22 |                 TABLE ACCESS FULL  | TEMP2_SL_SNAPSHOT_ENTRIES    |    56M|  2701M|       |   162K  (1)| 00:32:35 |  Q1,01 | PCWP |            |
    |  23 |     PX RECEIVE                     |                              |    35M|    18G|       | 82859   (1)| 00:16:35 |  Q1,05 | PCWP |            |
    |  24 |      PX SEND HASH                  | :TQ10004                     |    35M|    18G|       | 82859   (1)| 00:16:35 |  Q1,04 | P->P | HASH       |
    |  25 |       BUFFER SORT                  |                              |    12M|  8012M|       |            |          |  Q1,04 | PCWP |            |
    |  26 |        VIEW                        |                              |    35M|    18G|       | 82859   (1)| 00:16:35 |  Q1,04 | PCWP |            |
    |  27 |         UNION-ALL                  |                              |       |       |       |            |          |  Q1,04 | PCWP |            |
    |  28 |          PX BLOCK ITERATOR         |                              |    11 |  2255 |       |   923   (1)| 00:00:12 |  Q1,04 | PCWC |            |
    |* 29 |           TABLE ACCESS FULL        | UNBALANCED_SUBLEDGER_ENTRIES |    11 |  2255 |       |   923   (1)| 00:00:12 |  Q1,04 | PCWP |            |
    |* 30 |          HASH JOIN                 |                              |    35M|  7514M|       | 81936   (1)| 00:16:24 |  Q1,04 | PCWP |            |
    |  31 |           PX RECEIVE               |                              |    21 |   210 |       |     2   (0)| 00:00:01 |  Q1,04 | PCWP |            |
    |  32 |            PX SEND BROADCAST       | :TQ10002                     |    21 |   210 |       |     2   (0)| 00:00:01 |  Q1,02 | P->P | BROADCAST  |
    |  33 |             PX BLOCK ITERATOR      |                              |    21 |   210 |       |     2   (0)| 00:00:01 |  Q1,02 | PCWC |            |
    |* 34 |              TABLE ACCESS FULL     | ACCOUNT_NUMBERS              |    21 |   210 |       |     2   (0)| 00:00:01 |  Q1,02 | PCWP |            |
    |  35 |           PX BLOCK ITERATOR        |                              |    56M|    11G|       | 81840   (1)| 00:16:23 |  Q1,04 | PCWC |            |
    |  36 |            TABLE ACCESS FULL       | TEMP2_SL_SNAPSHOT_ENTRIES    |    56M|    11G|       | 81840   (1)| 00:16:23 |  Q1,04 | PCWP |            |
    Predicate Information (identified by operation id):
       3 - access("AGG"."COMPANY_CODE"="DET"."COMPANY_CODE" AND "AGG"."ACCOUNT_NUMBER"=SUBSTR("DET"."ACCOUNT_NUMBER",1,5) AND
                  "AGG"."TRANSACTION_ID"="DET"."TRANSACTION_ID" AND "AGG"."TRANSACTION_ID_TYPE"="DET"."TRANSACTION_ID_TYPE")
       7 - filter(ABS(SUM(SYS_OP_CSR(SYS_OP_MSR(SUM("Z"."AMOUNT"),MIN("Z"."ACCOUNTING_DATE")),0)))>=0.01)
      15 - filter("USE"."ACCOUNTING_DATE"<TO_DATE(' 2010-04-22 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "USE"."ACCOUNTING_DATE">=TO_DATE('
                  2010-04-21 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      16 - access("SE"."ACCOUNT_NUMBER"="AN"."ACCOUNT_NUMBER")
      20 - filter("AN"."SUBLEDGER_TYPE"='AC' OR "AN"."SUBLEDGER_TYPE"='C')
      29 - filter("ACCOUNTING_DATE"<TO_DATE(' 2010-04-22 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "ACCOUNTING_DATE">=TO_DATE(' 2010-04-21
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      30 - access("DET"."ACCOUNT_NUMBER"="AN"."ACCOUNT_NUMBER")
      34 - filter("AN"."SUBLEDGER_TYPE"='AC' OR "AN"."SUBLEDGER_TYPE"='C')
                    This query is failing due to TEMP issue (TEMP SPACE out of space)
    My TEMP tablespace is 70GB and no one is using TEMP space while this query is in execution.
    PGA=16 GB.
    What i can see from execution plan is : Two large resultsets AGG (13Million) and DET (135 Million) is being joined HASH JOIN BUFFERED. Which is getting spilled to TEMP space causing TEMP outage.
    Is there any way, i can re-write this query (probably using SUB QUERY FACTORING...WITH CLAUSE) so that reduce two times access to TEMP2_SL_SNAPSHOT_ENTRIES table. TEMP2_SL_SNAPSHOT_ENTRIES is 12 GB non partition table and i cannot use any other filter to restrict rows from this table.

    Adding more information here :
    Inner sub query (Which forms DET-bottom)
    select /*+ PARALLEL(det, 2) */  det.journal_entry_line_id, det.accounting_date, det.company_code, det.account_number, det.transaction_id,
    decode(det.transaction_id_type, 'CollectionID', 'SettlementGroupID', det.transaction_id_type) transaction_id_type,  det.amount, det.currency_code,
    det.debit_or_credit, det.category, det.subcategory, det.reference1, det.reference1_type, det.reference2, det.reference2_type, det.gl_batch_id, det.marketplace_id,
    det.cost_center, det.gl_product_line, det.location, det.project, det.sales_channel, det.created_by, det.creation_date, det.last_updated_by, det.last_updated_date
    from financials.temp2_sl_snapshot_entries det,financials.account_numbers an
    where det.account_number = an.account_number
    and an.subledger_type in ('C', 'AC');
    Plan hash value: 976020246
    | Id  | Operation               | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT        |                           |    35M|  7514M|   163K  (1)| 00:32:47 |        |      |            |
    |   1 |  PX COORDINATOR         |                           |       |       |            |          |        |      |            |
    |   2 |   PX SEND QC (RANDOM)   | :TQ10001                  |    35M|  7514M|   163K  (1)| 00:32:47 |  Q1,01 | P->S | QC (RAND)  |
    |*  3 |    HASH JOIN            |                           |    35M|  7514M|   163K  (1)| 00:32:47 |  Q1,01 | PCWP |            |
    |   4 |     BUFFER SORT         |                           |       |       |            |          |  Q1,01 | PCWC |            |
    |   5 |      PX RECEIVE         |                           |    21 |   210 |     2   (0)| 00:00:01 |  Q1,01 | PCWP |            |
    |   6 |       PX SEND BROADCAST | :TQ10000                  |    21 |   210 |     2   (0)| 00:00:01 |        | S->P | BROADCAST  |
    |*  7 |        TABLE ACCESS FULL| ACCOUNT_NUMBERS           |    21 |   210 |     2   (0)| 00:00:01 |        |      |            |
    |   8 |     PX BLOCK ITERATOR   |                           |    56M|    11G|   163K  (1)| 00:32:45 |  Q1,01 | PCWC |            |
    |   9 |      TABLE ACCESS FULL  | TEMP2_SL_SNAPSHOT_ENTRIES |    56M|    11G|   163K  (1)| 00:32:45 |  Q1,01 | PCWP |            |
    Predicate Information (identified by operation id):
       3 - access("DET"."ACCOUNT_NUMBER"="AN"."ACCOUNT_NUMBER")
       7 - filter("AN"."SUBLEDGER_TYPE"='AC' OR "AN"."SUBLEDGER_TYPE"='C')
    Statistics
             31  recursive calls
              3  db block gets
        1634444  consistent gets
        1625596  physical reads
            636  redo size
    1803659818  bytes sent via SQL*Net to client
         125054  bytes received via SQL*Net from client
          11331  SQL*Net roundtrips to/from client
              3  sorts (memory)
              0  sorts (disk)
       56645822  rows processedOther sub query (that forms AGG)
         select /*+ PARALLEL(se, 2) */  company_code, substr(se.account_number, 1, 5) account_number,transaction_id,
         decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type) transaction_id_type,se.amount,se.accounting_date
         from financials.temp2_sl_snapshot_entries se,financials.account_numbers an
         where se.account_number = an.account_number
         and an.subledger_type in ('C', 'AC');
    Plan hash value: 976020246
    | Id  | Operation               | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT        |                           |    35M|  2012M|   163K  (1)| 00:32:37 |        |      |            |
    |   1 |  PX COORDINATOR         |                           |       |       |            |          |        |      |            |
    |   2 |   PX SEND QC (RANDOM)   | :TQ10001                  |    35M|  2012M|   163K  (1)| 00:32:37 |  Q1,01 | P->S | QC (RAND)  |
    |*  3 |    HASH JOIN            |                           |    35M|  2012M|   163K  (1)| 00:32:37 |  Q1,01 | PCWP |            |
    |   4 |     BUFFER SORT         |                           |       |       |            |          |  Q1,01 | PCWC |            |
    |   5 |      PX RECEIVE         |                           |    21 |   210 |     2   (0)| 00:00:01 |  Q1,01 | PCWP |            |
    |   6 |       PX SEND BROADCAST | :TQ10000                  |    21 |   210 |     2   (0)| 00:00:01 |        | S->P | BROADCAST  |
    |*  7 |        TABLE ACCESS FULL| ACCOUNT_NUMBERS           |    21 |   210 |     2   (0)| 00:00:01 |        |      |            |
    |   8 |     PX BLOCK ITERATOR   |                           |    56M|  2701M|   162K  (1)| 00:32:35 |  Q1,01 | PCWC |            |
    |   9 |      TABLE ACCESS FULL  | TEMP2_SL_SNAPSHOT_ENTRIES |    56M|  2701M|   162K  (1)| 00:32:35 |  Q1,01 | PCWP |            |
    Predicate Information (identified by operation id):
       3 - access("SE"."ACCOUNT_NUMBER"="AN"."ACCOUNT_NUMBER")
       7 - filter("AN"."SUBLEDGER_TYPE"='AC' OR "AN"."SUBLEDGER_TYPE"='C')
    Statistics
             31  recursive calls
              3  db block gets
        1634444  consistent gets
        1625596  physical reads
            592  redo size
    1803659818  bytes sent via SQL*Net to client
         125054  bytes received via SQL*Net from client
          11331  SQL*Net roundtrips to/from client
              3  sorts (memory)
              0  sorts (disk)
       56645822  rows processed

  • How to write sql query that display comma suppurated result using Group by

    Hi,
    I am having data like bellow ,
    Above result got from joining two tables VMTAGroupClient,VMTAipNames .
    Query i have written to display above result is,
    select vgc.VMTAGroupId,vn.VMTAName from VMTAGroupClient vgc inner join VMTAipNames vn
    on vgc.VMTAID=vn.VMTANameID group by vgc.VMTAGroupId,vn.VMTAName 
    using the VMTAGroupId column how to write query to display result result like,
    VMTAGroupID    VMTAs
       1                       VMTA1,VMTA3
       2                       VMTA2,VMTA4,VMTA5
    Regards,
    Anwar Shaik

    Satheesh,
    Here in my case data need to read from two tables VMTAGroupClient, VMTAipNames.
    VMTAGroupId is in one table and VMTAName column in some other table.Iin both the tables VMTAID is common.
    Please check the above result displayed data from two tables.
    can we write same query using join?
    Anwar Shaik

  • Write a query for finding STDDEV for OLAP Cube

    Can anybody post a sample query which will find the standard deviation of sales for each month in the sample GLOBAL OLAP schema for Oracle 11g.
    The OLAP option automatically generates a set of relational views on cubes, dimensions, and hierarchies in Oracle 11g. So how can i write a query for finding the Standard deviation on these views.

    The easiest way to do this is to do this directly within the AW using a custom calculated measure. In AWM11g you can use the 11g custom measure wrapper to execute the STDDEV function:
    olap_dml_expression('function',data type)
    For example
    olap_dml_expression('STDDEV(cube_name, time_dimension_name)',number)
    You can then simply expose this calculated measure as another column in your SQL View and then there is no need to use the SQL equivalent. This means the calculation is performed inside the AW (which is as close to the source data as you can get) ensuring performance of the whole query remains high.
    If necessary you can take this a step further, if required, and wrap the STDDEV calculation within an OLAP DML program that would allow you to manipulate the status of time within the calculation. For example, you may want the STDDEV calc to only take into account the last 12 time periods rather than all time periods currently in status.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • How to write the query using Index

    Hi All,
    I have to fetch the records from Database table using Index, how can i write the query using Index. Can any body plz send me the sample code.
    Help Me,
    Balu.

    Hi,
    See the below Example.
    select * from vbak up to 100 rows
    into table t_vbak
    where vbeln > v_vbeln.
    sort t_vbak by vbeln descending.
    read table t_vbak index 1.
    Regards,
    Ram
    Pls reward points if helpful.

Maybe you are looking for

  • Data Federator with BW 3.5

    Hi Experts, We are using Data Federator and connected to our Client BW 3.5 Oracle Data base directly. We were looking to connect to below Cube and Ods tables InfoProviders Table Names InfoCube ZSD_BILDP /BIC/EZSD_BILDP, /BIC/FZSD_BILDP ODS Object ZDP

  • Layers won't collapse or open

    Illustrator running very slowly, problem with layers. Nothing happens when clicking on triangles to open and collapse layers. Can turn them on and off by clicking the eye. Can also create new layers and delete things. What should I do? Working in win

  • TDS Information

    Hi In my client company we have uploaded vendors masters through LSMW  at that time we did not give TDS information(TDS codes and Type) in the master record Till now we have not uploaded vendor balances from legacy to SAP Now my client are giving onl

  • Time Machine has been excluding items for hours... and counting!

    I have been using time capsule for several years now. But today I brought a new hard drive to use with Time Machine. It's a Western Digital My Book Network drive. Plugged it in selected the new disk and started to back up. For hours now it has been '

  • Rman controle file backup

    hi, RMAN>backup database on executing the above command does rman backsup the control file also???? Edited by: 793097 on Dec 7, 2010 12:49 AM