Please help to re-write this query using exists or with

Hi please help to re-write this query using exists or with, i need to write same code for 45 day , 90 days and so on but sub query condition is same for all
SELECT SUM (DECODE (t_one_mon_c_paid_us, 0, 0, 1)) t_two_y_m_mul_ca_
FROM (SELECT SUM (one_mon_c_paid_us) t_one_mon_c_paid_us
FROM (
SELECT a.individual_id individual_id,
CASE
WHEN NVL
(b.ship_dt,
TO_DATE ('05-MAY-1955')
) >= SYSDATE - 45
AND a.country_cd = 'US'
AND b.individual_id in (
SELECT UNIQUE c.individual_id
FROM order c
WHERE c.prod_cd = 'A'
AND NVL (c.last_payment_dt,
TO_DATE ('05-MAY-1955')
) >= SYSDATE - 745)
THEN 1
ELSE 0
END AS one_mon_c_paid_us
FROM items b, addr a, product d
WHERE b.prod_id = d.prod_id
AND d.affinity_1_cd = 'ADH'
AND b.individual_id = a.individual_id)
GROUP BY individual_id)
Edited by: user4522368 on Aug 23, 2010 9:11 AM

Please try and place \ before and after you code \Could you not remove the inline column select with the following?
SELECT a.individual_id individual_id
     ,CASE
        when b.Ship_dt is null then
          3
        WHEN b.ship_dt >= SYSDATE - 90
          3
        WHEN b.ship_dt >= SYSDATE - 45
          2
        WHEN b.ship_dt >= SYSDATE - 30
          1
      END AS one_mon_c_paid_us
FROM  items           b
     ,addr            a
     ,product         d
     ,order           o
WHERE b.prod_id       = d.prod_id
AND   d.affinity_1_cd = 'ADH'
AND   b.individual_id = a.individual_id
AND   b.Individual_ID = o.Individual_ID
and   o.Prod_CD       = 'A'             
and   NVL (o.last_payment_dt,TO_DATE ('05-MAY-1955') ) >= SYSDATE - 745
and   a.Country_CD    = 'US'

Similar Messages

  • Please help me re write this query

    select case
    when MONTHS>=6 then YRS++
         else YRS
    end,
    from some_tab
    Edited by: user9027633 on Feb 25, 2010 1:44 AM

    Hi,
    It sounds like you want to round the length of service to the nearest year; the rounded figure may as much as 6 months more or less than the actual length of service.
    How to do that depends on your data.
    If you have 2 separate columns, months (a number, where 0 <= months < 12) and yrs (an integer) then you could say
    select  case
                when MONTHS >= 6 then YRS+1
                                 else YRS
            end     AS rounded_service_years
    from    some_tab
    ;but you might find it easier to say:
    select  ROUND (yrs + (months / 12))     AS rounded_service_years
    from    some_tab
    ;

  • I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

    I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

    I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

  • PLease help me in wrirting this query

    Hi all,
    i want to write a query using standard emp table.But output required is like
    deptno ename
    10 smith
    alen
    mark
    20 ram
    hanuman
    Thus if deptno is same for some employees it should be printed once only
    Any help is highly appreciated

    SQL> select decode(row_number() over(partition by deptno order by ename),1, deptno, '') deptno,
      2         ename
      3    from emp
      4  /
        DEPTNO ENAME
            10 CLARK
               KING
               MILLER
            20 ADAMS
               FORD
               JONES
               SCOTT
               SMITH
            30 ALLEN
               BLAKE
               JAMES
               MARTIN
               TURNER
               WARD
    14 rows selected.or just in SQLPLUS for display purpose
    SQL> break on deptno
    SQL> select deptno, ename from emp order by deptno, ename
      2  /
        DEPTNO ENAME
            10 CLARK
               KING
               MILLER
            20 ADAMS
               FORD
               JONES
               SCOTT
               SMITH
            30 ALLEN
               BLAKE
               JAMES
               MARTIN
               TURNER
               WARD
    14 rows selected.Edited by: Karthick_Arp on Jun 1, 2009 11:33 PM

  • Sql Query Tuning. Please help me to tune this query

    Hi All ,
    I have this problematic Sql . It is taking huge time to execute. It contains a view CIDV, which i think is the bottleneck.
    I have pasted the query below. I will be pasting TKPROF and explain plan for the same. Please advice me to tune this query.
    SELECT GCC.SEGMENT1 || '.' || GCC.SEGMENT2 || '.' || GCC.SEGMENT3 || '.' ||
           GCC.SEGMENT4 || '.' || GCC.SEGMENT5 || '.' || GCC.SEGMENT6 || '.' ||
           GCC.SEGMENT7 || '.' || GCC.SEGMENT8 || '.' || GCC.SEGMENT9 OFFSET_ACCOUNT,
           OOD.ORGANIZATION_CODE,
           CIDV.SUBINVENTORY_CODE OFFSET_SUBINV,
           MIL.SEGMENT1 || '.' || MIL.SEGMENT2 || '.' || MIL.SEGMENT3 || '.' ||
           MIL.SEGMENT4 || '.' || MIL.SEGMENT5 OFFSET_LOCATOR,
           CIDV.LAST_UPDATE_LOGIN
      FROM APPS.CST_INV_DISTRIBUTION_V       CIDV,
           APPS.GL_CODE_COMBINATIONS         GCC,
           APPS.MTL_ITEM_LOCATIONS           MIL,
           APPS.ORG_ORGANIZATION_DEFINITIONS OOD
    WHERE CIDV.TRANSACTION_ID = :B2
       AND CIDV.PRIMARY_QUANTITY = (-1) * :B1
       AND CIDV.REFERENCE_ACCOUNT = GCC.CODE_COMBINATION_ID
       AND OOD.ORGANIZATION_ID = CIDV.ORGANIZATION_ID
       AND MIL.INVENTORY_LOCATION_ID = CIDV.LOCATOR_ID
       AND GCC.ACCOUNT_TYPE = 'A'****************
    TKPROF
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute  68337     10.32      10.32          0          0          0           0
    Fetch    68337    229.75     936.36      58819    6743323       1121       68232
    total   136675    240.07     946.69      58819    6743323       1121       68232
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 203     (recursive depth: 1)
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
             1          1          1  MERGE JOIN CARTESIAN (cr=102 pr=15 pw=0 time=193608 us cost=56 size=219 card=1)
             1          1          1   NESTED LOOPS  (cr=100 pr=15 pw=0 time=193483 us cost=53 size=219 card=1)
             1          1          1    NESTED LOOPS  (cr=99 pr=15 pw=0 time=193407 us cost=52 size=215 card=1)
             1          1          1     NESTED LOOPS  (cr=96 pr=15 pw=0 time=193378 us cost=51 size=190 card=1)
             1          1          1      NESTED LOOPS  (cr=93 pr=15 pw=0 time=193284 us cost=49 size=162 card=1)
             1          1          1       NESTED LOOPS  (cr=89 pr=14 pw=0 time=185515 us cost=46 size=138 card=1)
             1          1          1        NESTED LOOPS  (cr=85 pr=12 pw=0 time=157975 us cost=44 size=81 card=1)
             1          1          1         NESTED LOOPS  (cr=83 pr=12 pw=0 time=157925 us cost=43 size=73 card=1)
             1          1          1          NESTED LOOPS  (cr=81 pr=12 pw=0 time=157641 us cost=43 size=132 card=2)
             1          1          1           VIEW  CST_INV_DISTRIBUTION_V (cr=78 pr=12 pw=0 time=156386 us cost=41 size=118 card=2)
             1          1          1            UNION-ALL  (cr=78 pr=12 pw=0 time=156378 us)
             0          0          0             NESTED LOOPS OUTER (cr=44 pr=9 pw=0 time=124997 us cost=20 size=291 card=1)
             0          0          0              NESTED LOOPS  (cr=44 pr=9 pw=0 time=124993 us cost=18 size=255 card=1)
             0          0          0               NESTED LOOPS  (cr=44 pr=9 pw=0 time=124990 us cost=18 size=251 card=1)
            33         33         33                MERGE JOIN CARTESIAN (cr=25 pr=6 pw=0 time=98544 us cost=14 size=192 card=1)
             1          1          1                 NESTED LOOPS OUTER (cr=22 pr=5 pw=0 time=85754 us cost=12 size=156 card=1)
             1          1          1                  NESTED LOOPS  (cr=19 pr=4 pw=0 time=79830 us cost=10 size=120 card=1)
             1          1          1                   NESTED LOOPS OUTER (cr=17 pr=4 pw=0 time=79813 us cost=9 size=113 card=1)
             1          1          1                    NESTED LOOPS  (cr=15 pr=4 pw=0 time=79752 us cost=8 size=106 card=1)
             1          1          1                     NESTED LOOPS  (cr=11 pr=2 pw=0 time=43120 us cost=6 size=93 card=1)
             1          1          1                      NESTED LOOPS  (cr=7 pr=2 pw=0 time=43087 us cost=4 size=83 card=1)
             1          1          1                       NESTED LOOPS  (cr=6 pr=2 pw=0 time=43072 us cost=4 size=80 card=1)
             1          1          1                        TABLE ACCESS BY INDEX ROWID MTL_MATERIAL_TRANSACTIONS (cr=5 pr=2 pw=0 time=43042 us cost=4 size=76 card=1)
             1          1          1                         INDEX UNIQUE SCAN MTL_MATERIAL_TRANSACTIONS_U1 (cr=4 pr=2 pw=0 time=43011 us cost=3 size=0 card=1)(object id 12484094)
             1          1          1                        INDEX UNIQUE SCAN MTL_TRANSACTION_TYPES_U1 (cr=1 pr=0 pw=0 time=20 us cost=0 size=764 card=191)(object id 9983)
             1          1          1                       INDEX UNIQUE SCAN MTL_TXN_SOURCE_TYPES_U1 (cr=1 pr=0 pw=0 time=7 us cost=0 size=54 card=18)(object id 9987)
             1          1          1                      INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=4 pr=0 pw=0 time=27 us cost=2 size=736324450 card=73632445)(object id 12484155)
             1          1          1                     INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_TL_U1 (cr=4 pr=2 pw=0 time=36626 us cost=2 size=957481070 card=73652390)(object id 12484137)
             1          1          1                    TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=42 us cost=1 size=3290 card=470)
             1          1          1                     INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=28 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                   TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=12 us cost=1 size=3290 card=470)
             1          1          1                    INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=7 us cost=0 size=0 card=1)(object id 9847)
             0          0          0                  INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=1 pw=0 time=5915 us cost=2 size=36 card=1)(object id 705891)
            33         33         33                 BUFFER SORT (cr=3 pr=1 pw=0 time=12713 us cost=12 size=36 card=1)
            33         33         33                  INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=1 pw=0 time=12582 us cost=2 size=36 card=1)(object id 705891)
             0          0          0                TABLE ACCESS BY INDEX ROWID MTL_TRANSACTION_ACCOUNTS (cr=19 pr=3 pw=0 time=26591 us cost=4 size=59 card=1)
            66         66         66                 INDEX RANGE SCAN MTL_TRANSACTION_ACCOUNTS_N1 (cr=18 pr=2 pw=0 time=13607 us cost=3 size=0 card=3)(object id 12484127)
             0          0          0               INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=0 pr=0 pw=0 time=0 us cost=0 size=4 card=1)(object id 9847)
             0          0          0              INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=36 card=1)(object id 705891)
             1          1          1             NESTED LOOPS  (cr=34 pr=3 pw=0 time=31269 us cost=21 size=288 card=1)
             1          1          1              NESTED LOOPS  (cr=30 pr=3 pw=0 time=31161 us cost=19 size=275 card=1)
             1          1          1               NESTED LOOPS  (cr=26 pr=3 pw=0 time=31105 us cost=17 size=265 card=1)
             1          1          1                NESTED LOOPS  (cr=25 pr=3 pw=0 time=31082 us cost=17 size=261 card=1)
             1          1          1                 NESTED LOOPS OUTER (cr=23 pr=3 pw=0 time=31027 us cost=16 size=254 card=1)
             1          1          1                  NESTED LOOPS  (cr=21 pr=3 pw=0 time=30980 us cost=15 size=247 card=1)
             1          1          1                   NESTED LOOPS  (cr=20 pr=3 pw=0 time=30957 us cost=15 size=243 card=1)
             1          1          1                    NESTED LOOPS OUTER (cr=19 pr=3 pw=0 time=30926 us cost=15 size=240 card=1)
             1          1          1                     NESTED LOOPS  (cr=16 pr=3 pw=0 time=30389 us cost=13 size=204 card=1)
             1          1          1                      NESTED LOOPS  (cr=11 pr=0 pw=0 time=665 us cost=9 size=131 card=1)
             1          1          1                       NESTED LOOPS OUTER (cr=8 pr=0 pw=0 time=306 us cost=7 size=95 card=1)
             1          1          1                        TABLE ACCESS BY INDEX ROWID MTL_TRANSACTION_ACCOUNTS (cr=5 pr=0 pw=0 time=37 us cost=5 size=59 card=1)
             2          2          2                         INDEX RANGE SCAN MTL_TRANSACTION_ACCOUNTS_N1 (cr=4 pr=0 pw=0 time=17 us cost=4 size=0 card=3)(object id 12484127)
             1          1          1                        INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=216 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                       INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=352 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                      TABLE ACCESS BY INDEX ROWID MTL_MATERIAL_TRANSACTIONS (cr=5 pr=3 pw=0 time=29716 us cost=4 size=73 card=1)
             1          1          1                       INDEX RANGE SCAN MTL_MATERIAL_TRANSACTIONS_N23 (cr=4 pr=3 pw=0 time=29588 us cost=3 size=0 card=1)(object id 12484133)
             0          0          0                     INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=520 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                    INDEX UNIQUE SCAN MTL_TXN_SOURCE_TYPES_U1 (cr=1 pr=0 pw=0 time=22 us cost=0 size=3 card=1)(object id 9987)
             1          1          1                   INDEX UNIQUE SCAN MTL_TRANSACTION_TYPES_U1 (cr=1 pr=0 pw=0 time=16 us cost=0 size=4 card=1)(object id 9983)
             1          1          1                  TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=34 us cost=1 size=7 card=1)
             1          1          1                   INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=19 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                 TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=44 us cost=1 size=7 card=1)
             1          1          1                  INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=14 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=13 us cost=0 size=4 card=1)(object id 9847)
             1          1          1               INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=4 pr=0 pw=0 time=49 us cost=2 size=10 card=1)(object id 12484155)
             1          1          1              INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_TL_U1 (cr=4 pr=0 pw=0 time=96 us cost=2 size=13 card=1)(object id 12484137)
             1          1          1           TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=3 pr=0 pw=0 time=1246 us cost=1 size=7 card=1)
             1          1          1            INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=2 pr=0 pw=0 time=24 us cost=0 size=0 card=1)(object id 250158)
             1          1          1          INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=2 pr=0 pw=0 time=275 us cost=0 size=7 card=1)(object id 689101)
             1          1          1         TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=38 us cost=1 size=8 card=1)
             1          1          1          INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=15 us cost=0 size=0 card=1)(object id 9847)
             1          1          1        TABLE ACCESS BY INDEX ROWID GL_CODE_COMBINATIONS (cr=4 pr=2 pw=0 time=27531 us cost=2 size=57 card=1)
             1          1          1         INDEX UNIQUE SCAN GL_CODE_COMBINATIONS_U1 (cr=3 pr=1 pw=0 time=19925 us cost=1 size=0 card=1)(object id 51426)
             1          1          1       TABLE ACCESS BY INDEX ROWID MTL_ITEM_LOCATIONS (cr=4 pr=1 pw=0 time=7758 us cost=3 size=24 card=1)
             1          1          1        INDEX RANGE SCAN MTL_ITEM_LOCATIONS_U1 (cr=3 pr=0 pw=0 time=51 us cost=2 size=0 card=1)(object id 9761)
             1          1          1      TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=3 pr=0 pw=0 time=85 us cost=2 size=28 card=1)
             1          1          1       INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=2 pr=0 pw=0 time=29 us cost=1 size=0 card=2)(object id 5379798)
             1          1          1     TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=3 pr=0 pw=0 time=25 us cost=1 size=25 card=1)
             1          1          1      INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=2 pr=0 pw=0 time=11 us cost=1 size=0 card=1)(object id 5379798)
             1          1          1    INDEX FULL SCAN GL_SETS_OF_BOOKS_U2 (cr=1 pr=0 pw=0 time=69 us cost=1 size=4 card=1)(object id 1380842)
             1          1          1   BUFFER SORT (cr=2 pr=0 pw=0 time=110 us cost=55 size=0 card=1)
             1          1          1    TABLE ACCESS FULL FND_PRODUCT_GROUPS (cr=2 pr=0 pw=0 time=59 us cost=3 size=0 card=1)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      library cache lock                              2        0.00          0.00
      library cache pin                               2        0.00          0.00
      Disk file operations I/O                      249        0.00          0.00
      db file sequential read                     58819        2.61        714.28
      gc cr grant 2-way                            5198        0.16          4.52
      gc current grant busy                           1        0.00          0.00
      KJC: Wait for msg sends to complete           517        0.00          0.05
      library cache: mutex X                        433        0.01          0.04
      gc cr grant congested                          28        0.08          0.18
      latch: ges resource hash list                   5        0.00          0.00
      gc current block 2-way                        513        0.11          0.61
      gc current block congested                      2        0.00          0.00
      latch: gc element                              16        0.00          0.01
      latch: cache buffers chains                     4        0.00          0.00
      latch: object queue header operation            3        0.00          0.00
    ********************************************************************************

    Explain Plan for the query
    SELECT STATEMENT, GOAL = ALL_ROWS               Cost=56     Cardinality=1     Bytes=219
    MERGE JOIN CARTESIAN               Cost=56     Cardinality=1     Bytes=219
      NESTED LOOPS               Cost=53     Cardinality=1     Bytes=219
       NESTED LOOPS               Cost=52     Cardinality=1     Bytes=215
        NESTED LOOPS               Cost=51     Cardinality=1     Bytes=190
         NESTED LOOPS               Cost=49     Cardinality=1     Bytes=162
          NESTED LOOPS               Cost=46     Cardinality=1     Bytes=138
           NESTED LOOPS               Cost=44     Cardinality=1     Bytes=81
            NESTED LOOPS               Cost=43     Cardinality=1     Bytes=73
             NESTED LOOPS               Cost=43     Cardinality=2     Bytes=132
              VIEW     Object owner=APPS     Object name=CST_INV_DISTRIBUTION_V     Cost=41     Cardinality=2     Bytes=118
               UNION-ALL                         
                NESTED LOOPS OUTER               Cost=20     Cardinality=1     Bytes=291
                 NESTED LOOPS               Cost=18     Cardinality=1     Bytes=255
                  NESTED LOOPS               Cost=18     Cardinality=1     Bytes=251
                   MERGE JOIN CARTESIAN               Cost=14     Cardinality=1     Bytes=192
                    NESTED LOOPS OUTER               Cost=12     Cardinality=1     Bytes=156
                     NESTED LOOPS               Cost=10     Cardinality=1     Bytes=120
                      NESTED LOOPS OUTER               Cost=9     Cardinality=1     Bytes=113
                       NESTED LOOPS               Cost=8     Cardinality=1     Bytes=106
                        NESTED LOOPS               Cost=6     Cardinality=1     Bytes=93
                         NESTED LOOPS               Cost=4     Cardinality=1     Bytes=83
                          NESTED LOOPS               Cost=4     Cardinality=1     Bytes=80
                           TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS     Cost=4     Cardinality=1     Bytes=76
                            INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS_U1     Cost=3     Cardinality=1     
                           INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_TYPES_U1     Cost=0     Cardinality=191     Bytes=764
                          INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TXN_SOURCE_TYPES_U1     Cost=0     Cardinality=18     Bytes=54
                         INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_B_U1     Cost=2     Cardinality=73632445     Bytes=736324450
                        INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_TL_U1     Cost=2     Cardinality=73652390     Bytes=957481070
                       TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=470     Bytes=3290
                        INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                      TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=470     Bytes=3290
                       INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                     INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                    BUFFER SORT               Cost=12     Cardinality=1     Bytes=36
                     INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                   TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS     Cost=4     Cardinality=1     Bytes=59
                    INDEX RANGE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS_N1     Cost=3     Cardinality=3     
                  INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     Bytes=4
                 INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                NESTED LOOPS               Cost=21     Cardinality=1     Bytes=288
                 NESTED LOOPS               Cost=19     Cardinality=1     Bytes=275
                  NESTED LOOPS               Cost=17     Cardinality=1     Bytes=265
                   NESTED LOOPS               Cost=17     Cardinality=1     Bytes=261
                    NESTED LOOPS OUTER               Cost=16     Cardinality=1     Bytes=254
                     NESTED LOOPS               Cost=15     Cardinality=1     Bytes=247
                      NESTED LOOPS               Cost=15     Cardinality=1     Bytes=243
                       NESTED LOOPS OUTER               Cost=15     Cardinality=1     Bytes=240
                        NESTED LOOPS               Cost=13     Cardinality=1     Bytes=204
                         NESTED LOOPS               Cost=9     Cardinality=1     Bytes=131
                          NESTED LOOPS OUTER               Cost=7     Cardinality=1     Bytes=95
                           TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS     Cost=5     Cardinality=1     Bytes=59
                            INDEX RANGE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS_N1     Cost=4     Cardinality=3     
                           INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                          INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                         TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS     Cost=4     Cardinality=1     Bytes=73
                          INDEX RANGE SCAN     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS_N23     Cost=3     Cardinality=1     
                        INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                       INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TXN_SOURCE_TYPES_U1     Cost=0     Cardinality=1     Bytes=3
                      INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_TYPES_U1     Cost=0     Cardinality=1     Bytes=4
                     TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=7
                      INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                    TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=7
                     INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                   INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     Bytes=4
                  INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_B_U1     Cost=2     Cardinality=1     Bytes=10
                 INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_TL_U1     Cost=2     Cardinality=1     Bytes=13
              TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ALL_ORGANIZATION_UNITS     Cost=1     Cardinality=1     Bytes=7
               INDEX UNIQUE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_UNITS_PK     Cost=0     Cardinality=1     
             INDEX UNIQUE SCAN     Object owner=HR     Object name=HR_ALL_ORGANIZATION_UNTS_TL_PK     Cost=0     Cardinality=1     Bytes=7
            TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=8
             INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
           TABLE ACCESS BY INDEX ROWID     Object owner=GL     Object name=GL_CODE_COMBINATIONS     Cost=2     Cardinality=1     Bytes=57
            INDEX UNIQUE SCAN     Object owner=GL     Object name=GL_CODE_COMBINATIONS_U1     Cost=1     Cardinality=1     
          TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_ITEM_LOCATIONS     Cost=3     Cardinality=1     Bytes=24
           INDEX RANGE SCAN     Object owner=INV     Object name=MTL_ITEM_LOCATIONS_U1     Cost=2     Cardinality=1     
         TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATION     Cost=2     Cardinality=1     Bytes=28
          INDEX RANGE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATIO_FK2     Cost=1     Cardinality=2     
        TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATION     Cost=1     Cardinality=1     Bytes=25
         INDEX RANGE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATIO_FK2     Cost=1     Cardinality=1     
       INDEX FULL SCAN     Object owner=GL     Object name=GL_SETS_OF_BOOKS_U2     Cost=1     Cardinality=1     Bytes=4
      BUFFER SORT               Cost=55     Cardinality=1     
       TABLE ACCESS FULL     Object owner=APPLSYS     Object name=FND_PRODUCT_GROUPS     Cost=3     Cardinality=1     

  • Please Help Me to write a query

    I have a table called CLAIMs and I want to find out the rows which have the same claim and member id
    having cert ='MEMBER' and Insert date is greater than Other rows within the same claim and memberid.
    Eg:
    Insert date             claim                    member Id        cert     
    7/17/2009               2009106                  1345678         1345678 
    8/8/2009                2009106                  1345678         MEMBER 
    12/11/2009              2009107            1345679         MEMBER
    12/14/2009          2009107                   1345679         1345679
    Expected row:
    7/17/2009               2009106                  1345678         1345678 
    8/8/2009                2009106                  1345678         MEMBER  Please help.

    hoek wrote:
    Edited by: hoek on Dec 14, 2009 6:14 PMYour solution will show MEMBER even if there are no non-members for the claim, while OP stated:
    Insert date is greater than Other+* rows within the same claim and memberid
    SQL> with claims as (
      2                  select to_date('8/8/2009','mm/dd/yyyy') insert_date,2009106 claim,1345678 member_id,'MEMBER' cert from dual
      3                 )
      4  select *
      5  from   claims a
      6  where exists ( select null
      7                 from ( select b.insert_date
      8                        ,      b.claim
      9                        ,      b.member_id
    10                        ,      b.cert
    11                        ,      row_number() over (partition by b.claim, b.member_id order by b.insert_date desc) rn
    12                        from   claims b
    13                      ) b
    14                 where b.claim = a.claim
    15                 and   b.member_id = a.member_id
    16                 and   b.cert = 'MEMBER'
    17                 and   b.rn = 1
    18               );
    INSERT_DA      CLAIM  MEMBER_ID CERT
    08-AUG-09    2009106    1345678 MEMBER
    SQL> with claims as (
      2                  select to_date('8/8/2009','mm/dd/yyyy') insert_dt,2009106 claim,1345678 member_id,'MEMBER' cert from dual
      3                 )
      4  select  insert_dt,
      5          claim,
      6          member_id,
      7          cert
      8    from  (
      9           select  c.*,
    10                   max(case cert when 'MEMBER' then null else insert_dt end) over(partition by claim,member_id) max_non_member_dt,
    11                   max(case cert when 'MEMBER' then insert_dt end) over(partition by claim,member_id) max_member_dt
    12             from  claims c
    13          )
    14  where max_non_member_dt < max_member_dt
    15  /
    no rows selected
    SQL> SY.

  • Please help me to build this query

    hi,
    i have two tables a and b.
    i am inserting data into table a.
    i am inserting same data into table b.
    but i need to eleminate any duplicate rows in table b.
    this work should be done using trigger.
    means we need to write on insert trigger while inserting data into table a
    at the same time need to insert data into table b.
    final tables like this
    table a
    col1
    1234
    1234
    1234
    5678
    5678
    3456
    3456
    3456
    table b
    1234
    5678
    3456
    i really apricate your time and help

    hi
    thanks for your great support.
    if my table haveing more than 40 columns how can i
    write these queries
    insert into b (col1, col2) values (:new.col1,
    :new.col2);RTFM*: http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#SQLRF01604
    update b set col2=:new.col2 where col1=:new.col1;RTFM*: http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10007.htm#SQLRF01708
    I'll assume (since you didn't provide any details) that your unique key is composed of col1 and col3, for example. Then your update will be...
    update b set col2=:new.col2, col4=:new.col4, col5=:new.col5 ... col40=:new.col40
    where col1 = :new.col1 and col3 = :new.col3;
    *Read The "Fascinating" Manual if you want to learn the syntax.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to write this query using correlation subquery or non exists clause

    -- Tables description.
    --step-1- 4 employees present in EMP table.
    --step-2- each employee having 1 country_no in EMP_DOCS table.3 employees having same country_no(i.e emp's 1,2,3)
    --step-3- 1 emp document can have multiple items.In this case each employee having one each in the EMP_ITEMS table.
    --step-4- 1 EMPLOYEE  can have Multiple Documents so we have a relation between EMP_ITEMS and DOCUMENT_ITEMS.whatever items present in EMP_ITEMS those items will be inserted into DOCUMENT_ITEMS.so we have a item-item relation.
    --so we stored EMP_ITEMS id in EMP_ITEMS_REF_ID_1 of DOCUMENT_ITEMS table.
    -- step-5- DOCUMENT-INVOICE has 1-1 relation once invoice is created we stored invoice id in DOCUMENT table.
    --This is the requirement.Let's say in this example 3 employees are using same country_no and 4th employee is using another country_no
    --which is not used by other 3 employees.
    --Condtion-1:
    --if all of the employees have created INVOICE which is using same country_no of different country_no then the query should display all records.
    --Condition-2:
    --if any one of the employee not created INVOICE which is using same country_no of other employees then remaining employees also should not come in the query
    -- even though invoice is created by other employees.
    --Condition-3:
    --if any one of the employee not created even DOCUMENT  which is using same country_no of other employees then remaining employees also should not come in the query
    -- even though invoice is created by other employees.
    I hope I explain the conditions clearly.if you understand well by looking at the data i posted below may i know what is the final result should be displayed?
    create table EMP
      ID       NUMBER not null,
      TYPE     VARCHAR2(1)
    alter table EMP
      add constraint ID primary key (ID);
    create table EMP_DOCS
      ID         NUMBER not null,
      EMP_ID     NUMBER,
      COUNTRY_NO VARCHAR2(15)
    alter table EMP_DOCS
      add constraint PK_EMP_DT primary key (ID);
    alter table EMP_DOCS
      add constraint FK_EMP_DT foreign key (EMP_ID)
      references EMP (ID);
    create table EMP_ITEMS
      ID         NUMBER not null,
      EMP_DOC_ID     NUMBER
    alter table EMP_ITEMS
      add constraint PK_EMP_ITEMS_DT primary key (ID);
    alter table EMP_ITEMS
      add constraint FK_EMP_ITEMS_DT foreign key (EMP_DOC_ID)
      references EMP_DOCS (ID);
      create table DOCUMENT
      ID   NUMBER not null,
      DOCNO VARCHAR2(15),
      INVOICE_REF_1 NUMBER
    alter table DOCUMENT
      add constraint DOC_PK_ID primary key (ID);
      create table DOCUMENT_ITEMS
      ID         NUMBER not null,
      DOC_ID     NUMBER,
      EMP_ITEMS_REF_ID_1    NUMBER
    alter table DOCUMENT_ITEMS
      add constraint PK_DOCUMENT_ITEMS_DT primary key (ID);
    alter table DOCUMENT_ITEMS
      add constraint FK_DOCUMENT_ITEMS_DT foreign key (DOC_ID)
      references DOCUMENT (ID);
    create table INVOICE
      ID   NUMBER not null,
      INVOICE_NO VARCHAR2(15)
    alter table INVOICE
      add constraint INVOICE_PK_ID primary key (ID);
      INSERT INTO EMP ( ID, TYPE ) VALUES (
    1, 'A');
    INSERT INTO EMP ( ID, TYPE ) VALUES (
    2, 'A');
    INSERT INTO EMP ( ID, TYPE ) VALUES (
    3, 'A');
    INSERT INTO EMP ( ID, TYPE ) VALUES (
    4, 'A');
    INSERT INTO EMP_DOCS ( ID, EMP_ID, COUNTRY_NO ) VALUES (
    1, 1, 'INDIA');
    INSERT INTO EMP_DOCS ( ID, EMP_ID, COUNTRY_NO ) VALUES (
    2, 2, 'INDIA');
    INSERT INTO EMP_DOCS ( ID, EMP_ID, COUNTRY_NO ) VALUES (
    3, 3, 'INDIA');
    INSERT INTO EMP_DOCS ( ID, EMP_ID, COUNTRY_NO ) VALUES (
    4, 4, 'USA');
    INSERT INTO EMP_ITEMS ( ID, EMP_DOC_ID ) VALUES (
    1, 1);
    INSERT INTO EMP_ITEMS ( ID, EMP_DOC_ID ) VALUES (
    2, 2);
    INSERT INTO EMP_ITEMS ( ID, EMP_DOC_ID ) VALUES (
    3, 3);
    INSERT INTO EMP_ITEMS ( ID, EMP_DOC_ID ) VALUES (
    4, 4);
    INSERT INTO DOCUMENT ( ID, DOCNO, INVOICE_REF_1 ) VALUES (
    1, 'DOC1', 1);
    INSERT INTO DOCUMENT ( ID, DOCNO, INVOICE_REF_1 ) VALUES (
    2, 'DOC1', 2);
    INSERT INTO DOCUMENT ( ID, DOCNO, INVOICE_REF_1 ) VALUES (
    3, 'DOC3', 0);
    INSERT INTO DOCUMENT ( ID, DOCNO, INVOICE_REF_1 ) VALUES (
    4, 'DOC4', 3);
    INSERT INTO DOCUMENT_ITEMS ( ID, DOC_ID, EMP_ITEMS_REF_ID_1 ) VALUES (
    1, 1, 1);
    INSERT INTO DOCUMENT_ITEMS ( ID, DOC_ID, EMP_ITEMS_REF_ID_1 ) VALUES (
    2, 2, 2);
    INSERT INTO DOCUMENT_ITEMS ( ID, DOC_ID, EMP_ITEMS_REF_ID_1 ) VALUES (
    3, 2, 2);
    INSERT INTO DOCUMENT_ITEMS ( ID, DOC_ID, EMP_ITEMS_REF_ID_1 ) VALUES (
    4, 3, 3);
    INSERT INTO DOCUMENT_ITEMS ( ID, DOC_ID, EMP_ITEMS_REF_ID_1 ) VALUES (
    5, 4, 4);
    INSERT INTO INVOICE ( ID, INVOICE_NO ) VALUES (
    1, 'INV1');
    INSERT INTO INVOICE ( ID, INVOICE_NO ) VALUES (
    2, 'INV2');
    INSERT INTO INVOICE ( ID, INVOICE_NO ) VALUES (
    3, 'INV3');
    commit;
    -- I have written below query to satisfy above conditions but still required results are not coming..
    SELECT *
      FROM EMP E
    WHERE E.TYPE = 'A'
       AND NOT EXISTS (SELECT *
              FROM EMP_DOCS       EDOC1,
                   EMP_DOCS       EDOC2,
                   EMP            E1,
                   EMP_ITEMS      EMPI,
                   DOCUMENT_ITEMS DOCITM,
                   DOCUMENT       DOC,
                   INVOICE        INV
             WHERE EDOC1.EMP_ID = E.ID
               AND EDOC2.EMP_ID = E1.ID
               AND EDOC1.ID = EMPI.EMP_DOC_ID
               AND EDOC1.COUNTRY_NO = EDOC2.COUNTRY_NO
               AND EMPI.ID = DOCITM.EMP_ITEMS_REF_ID_1
               AND DOCITM.DOC_ID = DOC.ID
               AND INV.ID = DOC.INVOICE_REF_1);

    DB version:oracle 10g;10.2

  • Please help me in writing this query

    Hi all,
    How to do a token match of a string with the token of another mathc
    EX:
    LET THE FIRST STRINGS WITH A COMMA separated like below
    "firsttoken,second,third,are,the,parts,of,a,string"
    LET THE SECOND STRING WITH A COMMA separated like below
    "this,is,the,search,tokens"
    Now I have to match any token of the SECOND string with any TOKEN OF THE FIRST string
    If atleast one match is exist then its treated as success..
    I need only sql, not pl/sql
    Preferrable if analytical functions not used.
    Thanks in advance,
    Khaleel

    Khaleel,
    I understand the limitation to use PL/SQL. I have similar kind of limitations at my end, I am not allowed
    to leave any custom procedure/function definitions in the db with out taking the permissions for them.
    Here is the SQL solution for you for variable number of TOKENS. Only requirement is UPPER BOUND
    should be known. You could have variable number of tokens in either of the strings as long as you code it for the maximum number of tokens in each string. Here I coded it for 4 tokens in each string, hence I could use any number of tokens <= 4 in each string. Couple of tests here, -- Strings with different number of tokens but with a matching word
    SQL> SELECT DECODE(count(*), 0, 'MATCH NOT FOUND', 'MATCH FOUND') yes_no FROM DUAL,
      2  (SELECT DECODE(str1_comma1, 0, str1, SUBSTR(str1, 1, str1_comma1 - 1)) str1_token1,
      3          DECODE(str1_comma1, 0, NULL, decode(str1_comma2, 0, SUBSTR(str1, str1_comma1 + 1),
      4                    SUBSTR(str1, str1_comma1 + 1, str1_comma2 - str1_comma1 - 1))) str1_token2,
      5          DECODE(str1_comma2, 0, NULL, decode(str1_comma3, 0,  SUBSTR(str1, str1_comma2 + 1 ),
      6                    SUBSTR(str1, str1_comma2 + 1, str1_comma3 - str1_comma2 - 1))) str1_token3,
      7          DECODE(str1_comma3, 0, NULL, SUBSTR(str1, str1_comma3 + 1)) str1_token4,
      8          -- string2 tokens
      9          DECODE(str2_comma1, 0, str1, SUBSTR(str2, 1, str2_comma1 - 1)) str2_token1,
    10          DECODE(str2_comma1, 0, NULL, decode(str2_comma2, 0, SUBSTR(str2, str2_comma1 + 1),
    11                    SUBSTR(str2, str2_comma1 + 1, str2_comma2 - str2_comma1 - 1))) str2_token2,
    12          DECODE(str2_comma2, 0, NULL, decode(str2_comma3, 0,  SUBSTR(str2, str2_comma2 + 1 ),
    13                    SUBSTR(str2, str2_comma2 + 1, str2_comma3 - str2_comma2 - 1))) str2_token3,
    14          DECODE(str2_comma3, 0, NULL, SUBSTR(str2, str2_comma3 + 1)) str2_token4
    15  FROM
    16  (
    17  Select A.str1, Instr(A.str1, ',', 1, 1) str1_comma1,
    18                 Instr(A.str1, ',', 1, 2) str1_comma2,
    19            Instr(A.str1, ',', 1, 3) str1_comma3,
    20         B.str2,  Instr(B.str2, ',', 1, 1) str2_comma1,
    21             Instr(B.str2, ',', 1, 2) str2_comma2,
    22             Instr(B.str2, ',', 1, 3) str2_comma3
    23  From
    24  (Select 'Shaik,Khaleel,Java,Solution' str1 from dual) A,
    25  (Select 'SriDHAR,SQL,Solution' str2 from dual) B
    26  )
    27  ) X
    28  WHERE X.str2_token1 IN (X.str1_token1, X.str1_token2, X.str1_token3, X.str1_token4)
    29  OR    X.str2_token2 IN (X.str1_token1, X.str1_token2, X.str1_token3, X.str1_token4)
    30  OR    X.str2_token3 IN (X.str1_token1, X.str1_token2, X.str1_token3, X.str1_token4)
    31  OR    X.str2_token4 IN (X.str1_token1, X.str1_token2, X.str1_token3, X.str1_token4)
    32  /
    YES_NO
    MATCH FOUND
    -- Strings with same numer of tokens, with no matching word
    SQL> SELECT DECODE(count(*), 0, 'MATCH NOT FOUND', 'MATCH FOUND') yes_no FROM DUAL,
      2  (SELECT DECODE(str1_comma1, 0, str1, SUBSTR(str1, 1, str1_comma1 - 1)) str1_token1,
      3          DECODE(str1_comma1, 0, NULL, decode(str1_comma2, 0, SUBSTR(str1, str1_comma1 + 1),
      4                    SUBSTR(str1, str1_comma1 + 1, str1_comma2 - str1_comma1 - 1))) str1_token2,
      5          DECODE(str1_comma2, 0, NULL, decode(str1_comma3, 0,  SUBSTR(str1, str1_comma2 + 1 ),
      6                    SUBSTR(str1, str1_comma2 + 1, str1_comma3 - str1_comma2 - 1))) str1_token3,
      7          DECODE(str1_comma3, 0, NULL, SUBSTR(str1, str1_comma3 + 1)) str1_token4,
      8          -- string2 tokens
      9          DECODE(str2_comma1, 0, str1, SUBSTR(str2, 1, str2_comma1 - 1)) str2_token1,
    10          DECODE(str2_comma1, 0, NULL, decode(str2_comma2, 0, SUBSTR(str2, str2_comma1 + 1),
    11                    SUBSTR(str2, str2_comma1 + 1, str2_comma2 - str2_comma1 - 1))) str2_token2,
    12          DECODE(str2_comma2, 0, NULL, decode(str2_comma3, 0,  SUBSTR(str2, str2_comma2 + 1 ),
    13                    SUBSTR(str2, str2_comma2 + 1, str2_comma3 - str2_comma2 - 1))) str2_token3,
    14          DECODE(str2_comma3, 0, NULL, SUBSTR(str2, str2_comma3 + 1)) str2_token4
    15  FROM
    16  (
    17  Select A.str1, Instr(A.str1, ',', 1, 1) str1_comma1,
    18                 Instr(A.str1, ',', 1, 2) str1_comma2,
    19            Instr(A.str1, ',', 1, 3) str1_comma3,
    20         B.str2,  Instr(B.str2, ',', 1, 1) str2_comma1,
    21             Instr(B.str2, ',', 1, 2) str2_comma2,
    22             Instr(B.str2, ',', 1, 3) str2_comma3
    23  From
    24  (Select 'Shaik,Khaleel,Java,Program' str1 from dual) A,
    25  (Select 'SriDHAR,SQL,Solution,Possible' str2 from dual) B
    26  )
    27  ) X
    28  WHERE X.str2_token1 IN (X.str1_token1, X.str1_token2, X.str1_token3, X.str1_token4)
    29  OR    X.str2_token2 IN (X.str1_token1, X.str1_token2, X.str1_token3, X.str1_token4)
    30  OR    X.str2_token3 IN (X.str1_token1, X.str1_token2, X.str1_token3, X.str1_token4)
    31  OR    X.str2_token4 IN (X.str1_token1, X.str1_token2, X.str1_token3, X.str1_token4)
    32  /
    YES_NO
    MATCH NOT FOUNDLooks cumbersome, but works. You should be able to take it from here to extend the functionality also,
    like if you want to know which words are matching OR which words are not matching etc.., you should be
    able to tweak the SQL accordingly.
    Good luck,
    Thx,
    SriDHAR

  • Fixed Layout ePub - please help me embed video and/or use Folio overlay with web content

    Hi
    I have an In Design file used to create a print book (11"x11") and have decided to use CC 2014 to create a fixed-layout ePub 3 for a digital version.  I converted the book over with minor issues of having to change the font and it looks beautiful.
    I would like to add videos at the end of the book to take advantage of the flexibility of the digital format.  I create a year-end slideshow of my photos and host them on Vimeo.
    I have tried the following:
    Using the Vimeo standard embed code in an HTML element
    Using the old flash Vimeo embed code and converting to HTML - worked great on iBooks on Mac but not on iPhone/iPad as flash-based
    Hosting and linking to videos on my own web server and using the Media - insert video link to the mp4 file
    Hosting and linking to videos on my old photo server at smugmug.com
    I can embed the actual videos but, at their smallest size they increase the file size of the ePub from 78MB to 400MB...
    I then thought I would use a Folio Overlay - Web Content.
    The idea is to use this blank page on my website which would look for all intents and purposes like another white page in the book - 2012 Slideshow - Oren Photography
    The overlay works in Folio Preview but not when exported as an ePub
    Is this a limitation of the ePub format?
    Any help/advice/suggestions on fixing this are greatly appreciated.
    E

    Thanks again Steve and Bill
    My interest in embedding videos was largely to minimize the final file size and amount of space used on each person's device.  I ended up following your advice about using Adobe Media Encoder to minimize the size of each slideshow but it still increased the final ePub from 65 MB to over 200 MB.  And that was with video quality that was far inferior from what I could offer through an embed or, my final solution, a link out to my website.
    I happen to be of the same thought as Bill that most people are now connected to the internet and would favor a smaller file with access to online content over a very large file.  I would have liked to embed the videos and allow 720p quality inside the ePub over the link I ended up settling for.
    E

  • Urgent Help required in Tunning this query

    I have table ACCOUNT SPONSOR HOMESTORE ASH with more than 30 million rows.
    My batch daily need to update or insert into this table from a temporary table TEMP_HSTRALCT. The data for temporary table is populated by below query which selects from two tables TRANSACTION POINTS and REDEMPTIONS.However both these tables are partitioned on date time and is run daily and this is running for hours.
    Can anyone please help me on tuning this query
    INSERT INTO temp_hstralct
    (tmp_n_collector_account_num, tmp_v_location_id,
    tmp_v_sponsor_id, tmp_v_source_file_name,
    tmp_n_psc_insert_ind, tmp_n_psc_update_ind,
    tmp_n_transaction_amount, tmp_n_transaction_points,
    tmp_n_acc_insert_ind, tmp_n_ash_insert_ind,
    tmp_n_col_insert_ind, tmp_n_check_digit,
    tmp_n_collector_issue_num, tmp_n_csl_insert_ind,
    tmp_v_offer_code, tmp_n_psa_insert_ind)
    SELECT DISTINCT trp_n_collector_account_num account_num,
    trp_v_location_id location_id,
    trp_v_sponsor_id sponsor_id,
    trp_c_creation_user batch_id, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0
    FROM transaction_points, ACCOUNT, locations_master,homestores
    WHERE hsr_v_accrual_allowed = 'Y'
    AND trp_n_collector_account_num = ACCOUNT.acc_n_account_num(+)
    AND ( ( ( ACCOUNT.acc_v_account_type = 'C'
    OR ACCOUNT.acc_v_account_type IS NULL
    AND hsr_v_b2c_accounts = 'Y'
    OR ( ACCOUNT.acc_v_account_type = 'B'
    AND hsr_v_nfb_accounts = 'Y'
    OR ( ACCOUNT.acc_v_account_type = 'H'
    AND hsr_v_hybrid_accounts = 'Y'
    AND trp_d_creation_date_time BETWEEN SYSDATE-3
    AND SYSDATE
    AND trp_v_sponsor_id = 'JSAINSBURY'
    AND trp_v_location_id =
    locations_master.lnm_v_location_id
    AND locations_master.lnm_v_partner_id = 'JSAINSBURY'
    AND ( ( ( (INSTR
    (hsr_v_store_status,
    locations_master.lnm_c_location_status
    ) > 0
    AND (INSTR
    (hsr_v_store_type,
    locations_master.lnm_c_location_type
    ) > 0
    AND hsr_v_homestore_assignment = 'ST'
    OR ( ( locations_master.lnm_c_homestore_ind =
    'Y'
    AND (INSTR
    (hsr_v_store_status,
    locations_master.lnm_c_location_status
    ) > 0
    AND hsr_v_homestore_assignment = 'HS'
    UNION ALL
    SELECT DISTINCT rdm_n_collector_account_num account_num,
    rdm_v_location_id location_id,
    rom_v_supplier_id sponsor_id,
    rdm_c_creation_user batch_id, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0
    FROM redemption_details,
    reward_offer_master,
    ACCOUNT,
    locations_master,
    HOMESTORES
    WHERE hsr_v_redemption_allowed = 'Y'
    AND rdm_n_collector_account_num = ACCOUNT.acc_n_account_num(+)
    AND ( ( ( ACCOUNT.acc_v_account_type = 'C'
    OR ACCOUNT.acc_v_account_type IS NULL
    AND hsr_v_b2c_accounts = 'Y'
    OR ( ACCOUNT.acc_v_account_type = 'B'
    AND hsr_v_nfb_accounts = 'Y'
    OR ( ACCOUNT.acc_v_account_type = 'H'
    AND hsr_v_hybrid_accounts = 'Y'
    AND rdm_d_creation_date_time BETWEEN SYSDATE-3
    AND SYSDATE
    AND rom_v_reward_offer_id = rdm_v_reward_id
    AND rom_v_supplier_id = 'JSAINSBURY'
    AND rdm_v_location_id =
    locations_master.lnm_v_location_id
    AND locations_master.lnm_v_partner_id ='JSAINSBURY'
    AND ( ( ( (INSTR
    (hsr_v_store_status,
    locations_master.lnm_c_location_status
    ) > 0
    AND (INSTR
    (hsr_v_store_type,
    locations_master.lnm_c_location_type
    ) > 0
    AND hsr_v_homestore_assignment = 'ST'
    OR ( ( locations_master.lnm_c_homestore_ind =
    'Y'
    AND (INSTR
    (hsr_v_store_status,
    locations_master.lnm_c_location_status
    ) > 0
    AND hsr_v_homestore_assignment = 'HS'
    );

    I have copied the explain as it is and can you please try pasting in the text pad.Can you let me know whether parallel hint on this will speed up the select queries.
              Plan
              INSERT STATEMENT CHOOSECost: 410,815 Bytes: 2,798,394 Cardinality: 15,395                                                        
                   32 UNION-ALL                                                   
                        15 SORT UNIQUE Cost: 177,626 Bytes: 2,105,592 Cardinality: 11,896                                              
                             14 FILTER                                         
                                  13 HASH JOIN Cost: 177,312 Bytes: 2,105,592 Cardinality: 11,896                                    
                                       2 TABLE ACCESS BY INDEX ROWID LMHOLTP.LOCATIONS_MASTER Cost: 37 Bytes: 23,184 Cardinality: 966                               
                                            1 INDEX RANGE SCAN NON-UNIQUE LMHOLTP.IX_LOCATIONS_MASTER_3 Cost: 3 Cardinality: 1                          
                                       12 FILTER                               
                                            11 HASH JOIN OUTER                          
                                                 8 MERGE JOIN CARTESIAN Cost: 155,948 Bytes: 702,656,660 Cardinality: 4,845,908                     
                                                      3 TABLE ACCESS FULL LMHOLTP.HOMESTORES Cost: 2 Bytes: 104 Cardinality: 1                
                                                      7 BUFFER SORT Cost: 155,946 Bytes: 198,682,228 Cardinality: 4,845,908                
                                                           6 PARTITION RANGE ITERATOR Partition #: 12           
                                                                5 TABLE ACCESS BY LOCAL INDEX ROWID LMHOLTP.TRANSACTION_POINTS Cost: 155,946 Bytes: 198,682,228 Cardinality: 4,845,908 Partition #: 12      
                                                                     4 INDEX RANGE SCAN NON-UNIQUE LMHOLTP.IX_TRANSACTION_POINTS_1 Cost: 24,880 Cardinality: 6,978,108 Partition #: 12
                                                 10 PARTITION RANGE ALL Partition #: 15 Partitions accessed #1 - #5                    
                                                      9 TABLE ACCESS FULL LMHOLTP.ACCOUNT Cost: 6,928 Bytes: 68,495,680 Cardinality: 8,561,960 Partition #: 15 Partitions accessed #1 - #5               
                        31 SORT UNIQUE Cost: 233,189 Bytes: 692,802 Cardinality: 3,499                                              
                             30 FILTER                                         
                                  29 FILTER                                    
                                       28 NESTED LOOPS OUTER                               
                                            24 HASH JOIN Cost: 226,088 Bytes: 664,810 Cardinality: 3,499                          
                                                 16 TABLE ACCESS FULL LMHOLTP.REWARD_OFFER_MASTER Cost: 8 Bytes: 2,280 Cardinality: 114                     
                                                 23 HASH JOIN Cost: 226,079 Bytes: 8,327,280 Cardinality: 48,984                     
                                                      20 TABLE ACCESS BY INDEX ROWID LMHOLTP.LOCATIONS_MASTER Cost: 37 Bytes: 432 Cardinality: 18                
                                                           19 NESTED LOOPS Cost: 39 Bytes: 2,304 Cardinality: 18           
                                                                17 TABLE ACCESS FULL LMHOLTP.HOMESTORES Cost: 2 Bytes: 104 Cardinality: 1      
                                                                18 INDEX RANGE SCAN NON-UNIQUE LMHOLTP.IX_LOCATIONS_MASTER_3 Cost: 3 Cardinality: 966      
                                                      22 PARTITION RANGE ITERATOR Partition #: 28                
                                                           21 TABLE ACCESS FULL LMHOLTP.REDEMPTION_DETAILS Cost: 226,019 Bytes: 261,636,270 Cardinality: 6,229,435 Partition #: 28           
                                            27 PARTITION RANGE ITERATOR Partition #: 30                          
                                                 26 TABLE ACCESS BY LOCAL INDEX ROWID LMHOLTP.ACCOUNT Cost: 2 Bytes: 8 Cardinality: 1 Partition #: 30                     
                                                      25 INDEX UNIQUE SCAN UNIQUE LMHOLTP.CO_PK_ACCOUNT Cost: 1 Cardinality: 1 Partition #: 30

  • HT4623 Please  help!  i have just update my iphone 4s with 7.4 update and my phone is now asking for a password which i dont have.  I have tried my keypad lock i used before the update and also my itunes password and neither work, how do i rectify this ??

    Please  help!  i have just update my iphone 4s with 7.4 update and my phone is now asking for a password which i dont have.  I have tried my keypad lock i used before the update and also my itunes password and neither work, how do i rectify this ???

    Did you buy this iPhone new from an authorized seller?

  • Hi, when ever I'm using 3G, on my Iphone4 sim stops working and Network is lost, this started after I updated my phone with  6.0.1(10A523)version. Please help how to solve this problem.

    Hi, when ever I'm using 3G, on my Iphone4 sim stops working and network is lost, this started after I updated my phone with  6.0.1(10A523)version. Please help how to solve this problem. Thanks.

    Photos/videos in the Camera Roll are not synced. Photos/videos in the Camera Roll are not touched with the iTunes sync process. Photos/videos in the Camera Roll can be imported by your computer which is not handled by iTunes. Most importing software includes an option to delete the photos/videos from the Camera Roll after the import process is complete. If is my understanding that some Windows import software supports importing photos from the Camera Roll, but not videos. Regardless, the import software should not delete the photos/videos from the Camera Roll unless you set the app to do so.
    Photos/videos in the Camera Roll are included with your iPhone's backup. If you synced your iPhone with iTunes before the videos on the Camera Roll went missing and you haven't synced your iPhone with iTunes since they went missing, you can try restoring the iPhone with iTunes from the iPhone's backup. Don't sync the iPhone with iTunes again and decline the prompt to update the iPhone's backup after selecting Restore.

  • I upgraded to 20gb iCloud but it isn't enough to back up. I get constant error messages saying there is no backup space and I've not been able to use the upgrade. Apple promised to refund then didn't. Please help is there anyway I can use this space?

    Please see the subject line thanks
    I upgraded to 20gb iCloud but it isn't enough to back up. I get constant error messages saying there is no backup space and I've not been able to use the upgrade. Apple promised to refund then didn't. Please help is there anyway I can use this space?

    If you were told they would refund the price for the iCloud storage - Contact AppleCare and ask to speak with a senior advisor.  Have the case number for the promised refund available.
    If you are trying to update your device, but you don't have sufficient space to download and install the update, you need to delete content from your device.  Buying storage in iCloud does not add space to the device which is what you need.
    You can always update using a computer with iTunes installed - this method is faster, and will allow you to make a backup on the local computer (Local backups restore faster than iCloud backups).
    HTH

  • I just bought iWorks Serial Number Key over the internet. When I use the key, iWorks tells me the key is invalid!! Please help. (I bought this iWorks from someone in Singapore. I am using it in Malaysia)

    I just bought iWorks Serial Number Key over the internet. When I use the key, iWorks keep telling me the key is invalid!! Please help. (I bought this iWorks from someone in Singapore. I am using it in Malaysia.). Thanks

    Downloaded the Trial version. It still says the serial number key is invalid. On the iWork page where I am suppose to enter the serial number key, the "Go Back" button is always BOLD, but the "Continue" button remains GREY all the time. The "Continue" button remains grey even after I have completed the key entry. I have to type the "Return" key on my keyboard to force enter the key. The message I get is still "Invalid key".
    I have called Apple. The first person helped by asking me to delete certain items in some Folders and it still did not work. I was then connected to a senior person, but I heard over the recording that there were 15 persons waiting on the line. I had to end the call because the wait will take too long.

Maybe you are looking for

  • Print to Dot-Matrix-Printer

    Hi, My actual job is to create an Report in Oracle Reports 10, running on an IBM AIX Unix Server and direct the output to an Dot-Matrix Printer. The Report is ready for Preview. What Parameter should be set as Report_DesFormat for that Dot-Matrix Pri

  • ITunes 7 not playing downloaded videos?

    I had downloaded Quicktime 7.1.3 and iTunes 7, but my downloaded videos were not playing. I was also getting errors that iTunes was waiting to authorize computer and a gray video window screen. I removed the plug-in QuicktimeComponents from HD/Librar

  • HT5622 how do I share a video in my iCloud shared with someone?

    can someone tell me how to share a video that is in my ICloud Share via email?

  • Notebook VGA output, has it a digital signal?

    I have a Presario A900 (A961EM) with a VGA output. I want to connect it to my HDMI TV which has a HDMI socket. If I connect the laptop to my TV with a VGA to HDMI lead will it work with video and sound? This question was solved. View Solution.

  • Dreamweaver consistently quits

    Hello, We are having problems with one of our versions of Dreamweaver. On our Win7 PC's, we are having no problems with Dreamweaver, but on this Mac, the application consistently crashes. Crash log is below Process:         Dreamweaver [2872] Path: