How do i avoid OR cluase in this query

Can somebody please tell me how i can re-write the query to avoid the OR clause
so that i can use the index on WRKG38_VIN_FULL_C
we have following indexes on fact table.
1. composite index on (WRKG01_ORD_PROD_SRC_C and WRKG01_ORD_PROD_ORD_ID_C)
2. non-unique index on WRKG38_VIN_FULL_C
select fact.* from MWRKG01_GEVEXT_F fact, MWRKG38_DRIVER_ODS driv
where ( fact.WRKG01_ORD_PROD_SRC_C = driv.WRKG38_ORD_PROD_SRC_C) AND
( ( fact.wrkg01_ord_prod_ord_id_c = driv.wrkg38_ord_id_c ) OR
( fact.wrkg01_cnt_vin_full_c = driv.wrkg38_vin_full_c) ) and
driv.WRKG38_ACTION_C <> 'A';
explain plan:--
SELECT STATEMENT Optimizer=CHOOSE (Cost=75 Card=1 Bytes=2520)
SORT (AGGREGATE)
NESTED LOOPS (Cost=75 Card=45 Bytes=2520)
TABLE ACCESS (FULL) OF MWRKG38_DRIVER_ODS (Cost=1 Card=2 Bytes=58)
PARTITION (CONCATENATED)
TABLE ACCESS (BY LOCAL INDEX ROWID) OF MWRKG01_GEVEXT_F (Cost=37
Card=113915 Bytes=3075705)
INDEX (RANGE SCAN) OF MWRKG011 (NON-UNIQUE) (Cost=33 Card=113915)
Thank You

Hi Vijaya
You can try this. But I don't know it will improve the performance or not
select fact.* from MWRKG01_GEVEXT_F fact, MWRKG38_DRIVER_ODS driv
where ( fact.WRKG01_ORD_PROD_SRC_C = driv.WRKG38_ORD_PROD_SRC_C) AND
fact.wrkg01_ord_prod_ord_id_c = driv.wrkg38_ord_id_c
driv.WRKG38_ACTION_C <> 'A'
union
select fact.* from MWRKG01_GEVEXT_F fact, MWRKG38_DRIVER_ODS driv
where fact.WRKG01_ORD_PROD_SRC_C = driv.WRKG38_ORD_PROD_SRC_C) AND
fact.wrkg01_cnt_vin_full_c = driv.wrkg38_vin_full_c and
driv.WRKG38_ACTION_C <> 'A';
Good luck
Murali
Can somebody please tell me how i can re-write the query to avoid the OR clause
so that i can use the index on WRKG38_VIN_FULL_C
we have following indexes on fact table.
1. composite index on (WRKG01_ORD_PROD_SRC_C and WRKG01_ORD_PROD_ORD_ID_C)
2. non-unique index on WRKG38_VIN_FULL_C
select fact.* from MWRKG01_GEVEXT_F fact, MWRKG38_DRIVER_ODS driv
where ( fact.WRKG01_ORD_PROD_SRC_C = driv.WRKG38_ORD_PROD_SRC_C) AND
( ( fact.wrkg01_ord_prod_ord_id_c = driv.wrkg38_ord_id_c ) OR
( fact.wrkg01_cnt_vin_full_c = driv.wrkg38_vin_full_c) ) and
driv.WRKG38_ACTION_C <> 'A';
explain plan:--
SELECT STATEMENT Optimizer=CHOOSE (Cost=75 Card=1 Bytes=2520)
SORT (AGGREGATE)
NESTED LOOPS (Cost=75 Card=45 Bytes=2520)
TABLE ACCESS (FULL) OF MWRKG38_DRIVER_ODS (Cost=1 Card=2 Bytes=58)
PARTITION (CONCATENATED)
TABLE ACCESS (BY LOCAL INDEX ROWID) OF MWRKG01_GEVEXT_F (Cost=37
Card=113915 Bytes=3075705)
INDEX (RANGE SCAN) OF MWRKG011 (NON-UNIQUE) (Cost=33 Card=113915)
Thank You

Similar Messages

  • How can we avoid union all in this query.....

    Dear All,
    I have a query which has union all.I want a query with the same result without using union all.Can anyone help me?Here is my query.............
    SELECT DID,
    DM.DISTRICT_DESCRIPTION "DISTRICT_NAME",
    MID,
    DM.DISTRICT_DESCRIPTION || '(D)' "MANDAL_NAME",
    200706,
    'SD_OB' "EXP_CAT",
    SUM(NVL(AMOUNT,0))-SUM(NVL(AMOUNT1,0)) "AMOUNT" FROM
    (SELECT SUBSTR(AC.PCC_INFO_CODE,3,2) "DID", SUBSTR(AC.TRANSACTION_ID,6,2) "MID",NVL(SUM(AMOUNT),0) "AMOUNT", 0 "AMOUNT1"
    FROM ACCTD_CLAIMS AC
    WHERE TO_CHAR(AC.CLAIM_DATE,'YYYYMM') <= PREV_MONTH(200706)
    AND AC.HOA_ID='18 '
    AND SUBSTR(AC.TRANSACTION_ID,1,3) <> 'CRR'
    GROUP BY SUBSTR(AC.PCC_INFO_CODE,3,2),SUBSTR(AC.TRANSACTION_ID,6,2)
    union all
    SELECT SUBSTR(AC.PCC_INFO_CODE,3,2) "DID", SUBSTR(AC.TRANSACTION_ID,6,2) "MID",0 "AMOUNT" , NVL(SUM(AMOUNT),0) "AMOUNT1"
    FROM ACCTD_CLAIMS AC
    WHERE
    TO_CHAR(AC.PAY_DATE,'YYYYMM') <= PREV_MONTH(200706)
    AND AC.HOA_ID='18'
    GROUP BY SUBSTR(AC.PCC_INFO_CODE,3,2), SUBSTR(AC.TRANSACTION_ID,6,2)), DISTRICT_MASTER DM
    WHERE DM.DISTRICT_ID=DID
    GROUP BY DID, MID, DM.DISTRICT_DESCRIPTION;
    Regards,
    Krishnadeep.

    <I want a query with the same result without using union all>
    You can write a pipelined function, which will be about ten times the work. Its best to use the simples tools; why don't you want to use UNION ALL since its probably the best answer?

  • I have loaded and reloaded Reader 9.  I cannot open a pfd document.      I can save it to desk top then open it via a drop down box that has a "open with Adobe Reader 9".  How can I avoid having to do this?

    I have loaded and reloaded Reader 9.  I cannot open a pfd document.      I can save it to desk top then open it via a drop down box that has a "open with Adobe Reader 9".  How can I avoid having to do this?

    Hello Michael,
    Thank you for your response.  My operating system is XP.  When I try to open a pfd document I just get a series of letters and symbols in a dialog box.  The top of the box says "select the encoding that makes your document readable".  I can choose Windows, MS-Dos, or other (there is a long list to choose from).  None seem to make a difference.  If I save the document to my desk top I can right click on it and choose an option "Open with  AdobeReader 9" and it opens fine.
    Thank you,
    Rick 
    New Edge Technologies
    6525 Peninsula Dr.
    Traverse City, MI 49686
    231.620.2521
    231.941.1284 (fax)
    [email protected]
    Date: Wed, 8 Jul 2009 06:22:51 -0600
    From: [email protected]
    To: [email protected]
    Subject: I have loaded and reloaded Reader 9.  I cannot open a pfd document.      I can save it to desk top then open it via a drop down box that has a "open with Adobe Reader 9".  How can I avoid having to do this?
    Hello:
    What operating system does your computer use? What happens when you attempt to open a PDF document rather than saving it first? Please include any/all error messages. Also, have you tried opening documents from other locations or just one in particular?
    Thanks,
         Michael
    >

  • How can I use lead/lag in this query

    I have written this query which gives me the comparative data based on this week and next week. How can I use Lead/Lag in this query.
       WITH CURRENT_WEEK
              AS (  SELECT   QPAQ.YEAR YEAR,
                             QPAQ.SEASON SEASON,
                             REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+') ACC_SERIES,
                             TO_NUMBER (QPAQ.WEEK) WEEK,
                             MAX (QPAQ.FAILURES) FAILURES
                      FROM   QAR_PLAN_ACC_QTY QPAQ, QAR_PLAN_THRESHOLD_LST QPTL
                     WHERE       QPTL.CATEGORY_ID = 7
                             AND QPAQ.YEAR = QPTL.YEAR
                             AND QPAQ.SEASON = QPTL.SEASON
                             AND QPAQ.SERIES_NAME = QPTL.MODEL_SERIES
                  GROUP BY   QPAQ.YEAR,
                             QPAQ.SEASON,
                             REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+'),
                             TO_NUMBER (QPAQ.WEEK)
                  ORDER BY   REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+')),
           LAST_WEEK
              AS (  SELECT   QPAQ.YEAR YEAR,
                             QPAQ.SEASON SEASON,
                             REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+') ACC_SERIES,
                             TO_NUMBER (QPAQ.WEEK + 1) WEEK,
                             MAX (QPAQ.FAILURES) FAILURES
                      FROM   QAR_PLAN_ACC_QTY QPAQ, QAR_PLAN_THRESHOLD_LST QPTL
                     WHERE       QPTL.CATEGORY_ID = 7
                             AND QPAQ.YEAR = QPTL.YEAR
                             AND QPAQ.SEASON = QPTL.SEASON
                             AND QPAQ.SERIES_NAME = QPTL.MODEL_SERIES
                  GROUP BY   QPAQ.YEAR,
                             QPAQ.SEASON,
                             REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+'),
                             TO_NUMBER (QPAQ.WEEK)
                  ORDER BY   REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+'))
         SELECT   CURRENT_WEEK.YEAR,
                  CURRENT_WEEK.SEASON,
                  CURRENT_WEEK.ACC_SERIES,
                  CURRENT_WEEK.WEEK,
                  CURRENT_WEEK.FAILURES,
                  (CURRENT_WEEK.FAILURES - LAST_WEEK.FAILURES) FAILURES_COMPARE
           FROM   LAST_WEEK, CURRENT_WEEK
          WHERE   CURRENT_WEEK.WEEK = LAST_WEEK.WEEK(+)
       ORDER BY   CURRENT_WEEK.WEEK;Output is like this.
                    YEAR         SEASON     MODEL                     WEEK        FAILURES    Failures_COMPARE
    1     2011     SUMMER     VGP-BMS15     49     10     
    2     2011     SUMMER     VGP-BMS15     50     28       18
    3     2011     SUMMER     VGP-BMS15     51     30       2
    4     2011     SUMMER     VGP-BMS15     52     40       10Edited by: BluShadow on 06-Jan-2012 13:26
    added {noformat}{noformat} tags. Please read {message:id=9360002} to learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    You would jettison the entire LAST_WEEK subquery. Then replace your failure calculation with
        current_week.failure - lag(current_week.failure) over (order by current_week.year, current_week.week) as failures_compareI suppose you might want to think about renaming the sub-query as well ....
    Cheers, APC
    Edited by: APC on Jan 6, 2012 1:41 PM

  • How to remove the OR clause in this query?

    Hello Everyone,
    I have this query where i have a lot of joins and in the where clause there is a ISNULL and conditions based on OR clause.
    How to remove the use of the OR clause which may cause performance problems? Can anyone suggest a method to remove the OR clause?
    select RS.PLANNEDSTART,
    OD.ESTSHIPDATE
    FROM TABLE1 RS(NOLOCK)
         INNER JOIN TABLE2 SS(NOLOCK)
         ON RS.ID1             = SS.ID1
         INNER JOIN TABLE3 AM(NOLOCK)
         ON AM.KEYID        = SS.KEYID
         INNER JOIN TABLE4 OD(NOLOCK)
         ON SS.KEYID= OD.KEYID
        INNER JOIN TABLE 8 DR
       ON
    WHERE              (isnull(RS.DATE1,'1970-01-01 00:00:00.000') ='1970-01-01 00:00:00.000'
                     AND OD.DATE1 between @Beginning_Route_Date and @Ending_Route_Date)
                 OR
                 RS.DATE1!='1970-01-01 00:00:00.000'
                   AND RS.DATE1 BETWEEN  @Beginning_Route_Date and @Ending_Route_Date)              
    Regards
    Gautam S
    Gautam S

    this is one way avoiding OR clause
    WHERE CASE WHEN isnull(RS.DATE1,'1970-01-01 00:00:00.000') ='1970-01-01 00:00:00.000'
    THEN OD.DATE1 ELSE RS.DATE1 END between @Beginning_Route_Date and @Ending_Route_Date)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Could anyone help me to avoid Cartesian join in this query?

    Hi, guys:
    Could you help me on this query? I must generate a Cartesian join, but I do not know why it happens. dt.debtorkey, cl.clientkey, inv.invoicekey, ag.agingkey are primary keys of each table. The problem is: I got same tuple for 8 times.
    select dt.debtorkey, cl.clientkey,  inv.invoicekey, ag.agingkey, dt.DebtorNo, dt.Name as "debtor Name", dt.State,  cl.ClientNo, cl.Name as "Client Name",  inv.InvNo, inv.PurchOrd, inv.Amt,
    to_char(inv.InvDate, 'MM-DD-YY') invoice_date,  to_char(ag.DateLastBuy, 'MM-DD-YY') aging_lastbuy, to_char(ag.DateLastPmt, 'MM-DD-YY') aging_lastpmt
    from aging ag, invoices inv, debtors dt, clients cl
    where ag.clientkey=cl.clientkey
    and ag.debtorkey=dt.debtorkey
    and inv.clientkey=cl.clientkey
    and inv.debtorkey=dt.debtorkey
    and ((inv.InvDate>=to_date(:P16_DP_IDF_START_DATE, 'MM/DD/YYYY')
    and inv.InvDate<=to_date(:P16_DP_IDF_END_DATE, 'MM/DD/YYYY')
    and ag.DateLastBuy=to_date(:P16_DP_IDF_LAST_BUY,'MM/DD/YYYY')
    order by dt.name;Thanks a lot!

    Hi,
    Thanks for help. I am sorry for that I do not know how to upload a picture of explain plan. I am struggling to find how to provide sample data. I hope this data format could be at least useful.
    "DEBTORKEY","CLIENTKEY","INVOICEKEY","AGINGKEY","DEBTORNO","debtor Name","STATE","CLIENTNO","Client Name","INVNO","PURCHORD","AMT","INVOICE_DATE"
    8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
    8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
    8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
    8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
    8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
    8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
    8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
    8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
    8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
    8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
    8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
    8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
    8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
    8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
    8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
    8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
    8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
    8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
    8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
    8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
    8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
    8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
    8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
    8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"I do not know why the tuples with same primary key repeat 8 times.
    Edited by: lxiscas on Oct 24, 2012 4:08 PM
    Edited by: lxiscas on Oct 24, 2012 4:10 PM

  • How to improve the run time of this query

    Is there any way to improve this query,
    I have a table which SR_WId with atleast one subtype as 'Break Fix', 'Break/Fix','Break Fix/Corrective Maint','Break Fix-Corrective Maint'. then i can have other subtype as 'Break Fix', 'Break/Fix', 'Follow Up', 'Follw-Up','T&'||'M Break Fix','Break Fix/Corrective Maint','Break Fix-Corrective Maint'.
    Let me know if this is okay or to modify it.
    SELECT DISTINCT A.SR_WID AS SR_WID
    FROM WC_SR_ACT_SMRY_FS A
    WHERE EXISTS
    (SELECT NULL FROM WC_SR_ACT_SMRY_FS B
    WHERE B.ACT_TYPE = 'Maintenance'
    AND B.ACT_SUBTYPE in ('Break Fix', 'Break/Fix','Break Fix/Corrective Maint','Break Fix-Corrective Maint') AND B.NBR_OF_ACTIVITIES = 1 AND B.SR_WID = A.SR_WID
    GROUP BY B.SR_WID
    HAVING COUNT(B.SR_WID) >= 1)
    AND A.ACT_TYPE = 'Maintenance'
    AND A.ACT_SUBTYPE IN ('Break Fix', 'Break/Fix', 'Follow Up', 'Follw-Up','T&'||'M Break Fix','Break Fix/Corrective Maint','Break Fix-Corrective Maint')

    SELECT DISTINCT A.SR_WID AS SR_WID
               FROM WC_SR_ACT_SMRY_FS A
              WHERE EXISTS(
                       SELECT   NULL
                           FROM WC_SR_ACT_SMRY_FS B
                          WHERE B.ACT_TYPE = 'Maintenance'
                            AND B.ACT_SUBTYPE IN
                                  ('Break Fix',
                                   'Break/Fix',
                                   'Break Fix/Corrective Maint',
                                   'Break Fix-Corrective Maint')
                            AND B.NBR_OF_ACTIVITIES = 1
                            AND B.SR_WID = A.SR_WID
                       GROUP BY B.SR_WID
                         HAVING COUNT(B.SR_WID) >= 1 )
                AND A.ACT_TYPE = 'Maintenance'
                AND A.ACT_SUBTYPE IN
                      ('Break Fix',
                       'Break/Fix',
                       'Follow Up',
                       'Follw-Up',
                       'T&' || 'M Break Fix',
                       'Break Fix/Corrective Maint',
                       'Break Fix-Corrective Maint');First of all, you can omit the GROUP BY and HAVING part in the sub-select -
    we already know thath the only value for B.SR_WID can be A.SR_WID and
    COUNT(B.SR_WID) will always be at least 1, otherwise the sub-select will
    return nothing.
    As a second step, you could transform EXISTS() into IN():
    SELECT DISTINCT SR_WID
               FROM WC_SR_ACT_SMRY_FS A
              WHERE SR_WID IN(
                       SELECT B.SR_WID
                         FROM WC_SR_ACT_SMRY_FS B
                        WHERE B.ACT_TYPE = 'Maintenance'
                          AND B.ACT_SUBTYPE IN
                                ('Break Fix',
                                 'Break/Fix',
                                 'Break Fix/Corrective Maint',
                                 'Break Fix-Corrective Maint')
                          AND B.NBR_OF_ACTIVITIES = 1)
                AND ACT_TYPE = 'Maintenance'
                AND ACT_SUBTYPE IN
                      ('Break Fix',
                       'Break/Fix',
                       'Follow Up',
                       'Follw-Up',
                       'T&' || 'M Break Fix',
                       'Break Fix/Corrective Maint',
                       'Break Fix-Corrective Maint');

  • How to check multiple special characters in this query.

    When the master_title has no comma in it, I am getting an empty master_title. This is because INSTR(master_title,',',1,1) is returning 0.
    In addition, I want to be able to specify other characters besides the comma. Example: ":" "/" "-".
    Can we fit these options in the INSTR to look for them as well?
    Query given below.
    SELECT DISTINCT e.brm_id, SUBSTR(master_title,1,INSTR(master_title,',',1,1)-1) master_title
    FROM e_m_view e
    WHERE e.asset_dist LIKE'%WBPI Germany%'
    OR e.asset_dist LIKE '%krupp%'
    OR e.asset_dist IN (SELECT FN_SETRPTG(FN_GETPIREGN('%WBPI%')) FROM dual)
    AND e.kl='Live' AND NVL(wbpi_publish_date,SYSDATE) <= SYSDATE
    ORDER BY 2 ASC;
    ---------------------

    This?
    SQL> with t as(
      2  select 'abcd,efgh' name from dual union all
      3  select 'abcd:efgh'  from dual union all
      4  select 'abcd/efgh'  from dual union all
      5  select 'abcd-efgh'  from dual )
      6  select regexp_substr(name,'[^,:/-]+') name
      7  from t;
    NAME
    abcd
    abcd
    abcd
    abcd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How can I add reconciled payments to this query

    Select T4.[SlpName] as 'Sales Employee', T0.CardCode, T0.cardname as 'Customer',T0.Docdate as 'Invoice Date', T0.docnum as 'Invoice Number', T0.Taxdate as 'Month Of Service',isnull(T0.U_AIS_DVISFSO,T3.U_AIS_DVISFSO) as 'SO#',T0.NumAtCard as 'PO#', isnull(T0.U_AIS_DVIAdvNm,T3.U_AIS_DVIAdvNm) as 'Advertiser', isnull(T0.U_AIS_DVIOpptyNm,T3.U_AIS_DVIOpptyNm) as 'Campaign',T1.Dscription,-T1.Quantity as 'Impressions',T1.Pricebefdi as 'CPM', Case T0.CurSource When 'C' Then T0.DocCur When 'L' Then T5.MainCurncy When 'S' Then T6.SysCurrncy End As 'Currency DC', Case T0.CurSource When 'C' Then -T1.TotalFrgn When 'L' Then -T1.LineTotal When 'S' Then -T1.TotalSumSy End As 'Total Bef Discount DC', Case T0.CurSource When 'L' Then -T1.[LineVat] When 'C' Then -T1.[LineVatlF] When 'S' Then -T1.[LineVatS] END As 'Vat Tax DC', Case when t1.visorder = 0 Then (Cast(Round((Case T0.CurSource When 'L' Then -T0.DocTotal When 'C' Then -T0.DocTotalFC When 'S' Then -T0.DocTotalSy End), 2) As DECIMAL(18,2))) ELSE 0 END As 'Doc Total DC', Case when t1.visorder = 0 Then (Cast(Round((Case T0.CurSource When 'L' Then -(T0.DocTotal - T0.PaidToDate) When 'C' Then -(T0.DocTotalFC - T0.PaidFC) When 'S' Then -(T0.DocTotalSy - T0.PaidSys) End), 2) As DECIMAL(18,2))) ELSE 0 END As 'Balance after Payment DC', ISNULL(T6.SysCurrncy,'USD') As 'Currency SC', -T1.TotalSumSy As 'Total Bef Discount SC', -T1.[LineVatS] As 'Vat Tax SC', Case when t1.visorder = 0 Then (Cast(Round(-(T0.DocTotalSy), 2) As DECIMAL(18,2))) ELSE 0 END As 'Doc Total SC', Case when t1.visorder = 0 Then (Cast(Round(-(T0.DocTotalSy - T0.PaidSys), 2) As DECIMAL(18,2))) ELSE 0 END As 'Balance after Payment SC', T0.docstatus, 'Credit Memo' AS TransactionType, T0.CurSource,T0.[Comments],T0.[U_InvoiceAdj], T0.[U_DV_AdjustInvReason],T1.[U_DVIInvName], T1.[U_InvoiceAdj], T1.[U_DV_AdjustInvReason] from ORIN T0 left outer join RIN1 T1 on T0.docentry = T1.docentry left outer join RDR1 T2 on T1.Baseentry = T2.docentry and T1.baseline = T2.linenum left outer join ORDR T3 on T2.docentry = T3.docentry left outer join OSLP T4 ON T0.Slpcode= T4.Slpcode Left Join OADM T5 On T0.CurSource = 'L' Left Join OADM T6 On T0.CurSource = 'S' Where T0.cardname  Like '%[%0]%' and T0.docstatus ='O'

    Hi,
    Please check OITR,ITR1 Tables.
    Thanks,
    Nithi

  • How can i LPAD and/or RPAD this query in sql

    Hi,
    I have a column in a table with value 'True Wheel '. I want the result in the following format:
    'True*Wheel*****'
    i.e I want to pad '*' on the right as well as at the centre of the two words. Is it possible ?
    Please help !

    SQL>
    SQL> with x as (
      2    select 'True Wheel' as str from dual union all
      3    select 'True  Wheel' from dual union all
      4    select 'True   Wheel' from dual union all
      5    select 'True    Wheel' from dual union all
      6    select 'True     Wheel' from dual union all
      7    select 'True      Wheel' from dual)
      8  --
      9  select str, rpad(replace(str,' ','*'),15,'*') as mod_str
    10  from x;
    STR                  MOD_STR
    True Wheel           True*Wheel*****
    True  Wheel          True**Wheel****
    True   Wheel         True***Wheel***
    True    Wheel        True****Wheel**
    True     Wheel       True*****Wheel*
    True      Wheel      True******Wheel
    6 rows selected.
    SQL>
    SQL>cheers,
    pratz

  • How to reduce the elapsed time on this query.

    Oracle10.2.0.5 on AIX6.1.
    Here is the awrsql report of a query for a one hour window.
    Here UNBILLED has 120million records which is partitioned and subpartitioned. It has 10 partitions and 312 subpartitions. One subpartition has 10M records, 10 others have 1M each and 270 subpartitions have 360K records each. And 31 subpartitions are empty.
    And BILLED has 300K records.
    Looking at report you can see that out of 984 seconds, 958 is used for IO. Machine is PowerPC_POWER5 with 8CPU and disk storage on EMC.
    Stat Name                                Statement   Per Execution % Snap
    Elapsed Time (ms)                           984,327        5,561.2    28.6
    CPU Time (ms)                                40,760          230.3    29.8
    Executions                                      177            N/A     N/A
    Buffer Gets                               1,923,456       10,867.0    46.9
    Disk Reads                                  203,832        1,151.6    25.1
    Parse Calls                                       0            0.0     0.0
    Rows                                        106,200          600.0     N/A
    User I/O Wait Time (ms)                     958,766            N/A     N/A
    Cluster Wait Time (ms)                            0            N/A     N/A
    Application Wait Time (ms)                        0            N/A     N/A
    Concurrency Wait Time (ms)                        0            N/A     N/A
    Invalidations                                     0            N/A     N/A
    Version Count                                     1            N/A     N/A
    Sharable Mem(KB)                                 31            N/A     N/A
    SQL_ID akg45a750sh0u
    DELETE UNBILLED WHERE (MSG_ID, MSG_ID2,SPLIT_ROW_NUM) IN (SELECT MSG_ID,MSG_ID2, SPLIT_ROW_NUM FROM BILLED
    WHERE BILL_REF_NO = :B2 AND BILL_REF_RESETS = :B1 )
    Plan hash value: 3879210699
    | Id  | Operation                            | Name                          | Rows  | Bytes | Cost (%CPU)| Pstart| Pstop |
    |   0 | DELETE STATEMENT                     |                               |       |       |     1 (100)|       |       |
    |   1 |  DELETE                              | UNBILLED                      |       |       |            |       |       |
    |   2 |   NESTED LOOPS                       |                               |     1 |   112 |     0   (0)|       |       |
    |   3 |    TABLE ACCESS BY GLOBAL INDEX ROWID| BILLED                        |     1 |    65 |     0   (0)|     1 |     1 |
    |   4 |     INDEX RANGE SCAN                 | BILLED_XCB_BILL_REF_TRANS     |     1 |       |     0   (0)|       |       |
    |   5 |    INDEX UNIQUE SCAN                 | UNBILLED_PK                   |     1 |    47 |     0   (0)|       |       |
    ----------------------------------------------------------------------------------------------------------------------Is there way to improve the elapsed time( currently 5,561.2 msec per execution) of the query?
    Thanks for your time...

    user1014212 wrote:
    You're giving very interresting pointers.. Especially the one using the GTT table... Thanks...
    I was also looking from a DBA point of view, say increasing the DB_CACHE_SIZE from 5GB to 8GB as the machine has almost 32GB memory out of which 13GB is free memory. Because the timed event is "db file sequential read" which takes 95% of Total Call time.
    select * from V_$SGA_TARGET_ADVICE;
    post SQL & FORMATTED results using tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How do I avoid the recipient of my Indesign PDF receiving a security warning when clicking on links?

    I create PDF's out of Indesign to send to new clients. They contain links to external websites. They do not contain any javascript or videos or hidden links. If the PDF is opened in Adobe Reader, when the recipient clicks on a hyperlink in my PDF they get a security warning asking if they trust the site. How can I avoid the recipient receiving this Security Warning as it would scare people into thinking I had sent them something malicious when I haven't?

    You cannot avoid it, that's part of the PDF security system to make the user aware that he is entering non-trusted area, as it is with every web page when it is opened the first time in Reader or Acrobat on this computer. ThatÄs an unchageable fact. You have to live with it.

  • How do I avoid the recipient of my PDF receiving a security warning when clicking on hyperlinks?

    I create PDF's out of Indesign to send to new clients. They contain links to external websites. They do not contain any javascript or videos or hidden links. If the PDF is opened in Adobe Reader, when the recipient clicks on a hyperlink in my PDF they get a security warning asking if they trust the site. How can I avoid the recipient receiving this Security Warning as it would scare people into thinking I had sent them something malicious when I haven't?

    There's nothing you can do as the creator of the file. If you could, that whole source of security would be worthless.
    They would need to tweak their security settings in Edit>Preferences>Security(enhanced).

  • How we cn avoid the sequence in remote tables through global temporary tabl

    Hi,
    We have table xx_interface_qualifiers in the remote db and we are inserting the data like this and its on a loop
    INSERT INTO xx_interface_qua
    (interface_id,
    list_line_interface_id, excluder_flag,
    qualifier_context, qualifier_attribute,
    qualifier_attr_value, qualifier_precedence,
    comparison_operator_code, start_date_active,
    end_date_active, list_header_name, list_line_no,
    creation_date, created_by, last_update_date,
    last_updated_by, interface_attribute1
    VALUES (xx_interface_qua_s.NEXTVAL,
    ttt, 'Y',
    xxx, xxx2,
    xxx3, xxx4,
    '=', SYSDATE,
    NULL, xxx4, -1,
    SYSDATE, '-1', SYSDATE,
    '-1', 44 );
    We are trying to avoid the hitting of the database every time for a sequence and try to implement the global temporary tables,i mean to say 1st we need to insert the data to TEMP table and then from temp table we cn inseert all the data to xx_interface_qual in a single shot to improve the performance.
    But how we cn avoid the sequence in this case as we do not know the sequence in remote side.
    Please suggest any other way to improve the performance.
    Regards
    Das

    797846 wrote:
    We have table xx_interface_qualifiers in the remote db and we are inserting the data like this and its on a loop
    We are trying to avoid the hitting of the database every time for a sequence and try to implement the global temporary tables,i mean to say 1st we need to insert the data to TEMP table and then from temp table we cn inseert all the data to xx_interface_qual in a single shot to improve the performance.
    But how we cn avoid the sequence in this case as we do not know the sequence in remote side.Does not make sense. I/O is the slowest database operation.
    You have an unknown performance problem (that you claim is due to a sequence, but failed to provide any evidence for). Now you want to create more I/O, by writing the data twice. Once into a temp table and then again into the destination table. And do that in order to increase performance?
    I do not see how this can solve the underlying, and unknown, performance issue that you claim exists.
    Any problem solution needs to start with correctly and comprehensively identifying the problem.
    You cannot solve a problem without first knowing WHAT the problem is.

  • How to modify this query to get the desired output format

    I hv written a Query to display all the parent table names and their primary key columns(relevant to this foreign key of the child table).The query is given below...
    SELECT DISTINCT(TABLE_NAME) AS PARENT_TABLE,COLUMN_NAME AS PARENT_COLUMN
    FROM ALL_CONS_COLUMNS
    WHERE CONSTRAINT_NAME IN (SELECT AC.R_CONSTRAINT_NAME
    FROM ALL_CONSTRAINTS AC
    WHERE AC.TABLE_NAME=TABLE_NAME
    AND AC.TABLE_NAME='&TABLE'
    AND AC.R_CONSTRAINT_NAME IS NOT NULL);
    This query will display all the parent tables and their primary key columns.Now my problem is that how to modify this query to also display the foreign key column name of the child table.
    I want the query result in the following format.The query should display the following columns.1)child table's name,2)child table's foreign key column name,3)the corresponding parent table's name,4)the parent table's primary key column name(which is the foreign key in the child table).
    For Example I want the output as follows...
    TAKE THE CASE OF SCOTT.EMP(AS INPUT TO YOUR QUERY)
    CHILD_TABLE CHILD_COLUMN PARENT_TABLE PARENT_COLUMN
    EMP DEPTNO DEPT DEPTNO
    In this result I hv used alias name for the columns.The query should display this only for the foreign keys in the child table.In the query which I sent to you earlier will give the parent table and the parent column names,But I also want to append the child table and child column names there.
    any help on how to tackle would be appreciated.

    Try this query
    SELECT c.table_name child_table,
         c.column_name child_column,
         p.table_name parent_table,
         p.column_name parent_column
    FROM user_constraints a,user_constraints b,user_cons_columns c,
         user_cons_columns p
    WHERE a.r_constraint_name=b.constraint_name and
          a.constraint_name=c.constraint_name and
          b.constraint_name=p.constraint_name and
          c.position=p.position
    ORDER BY c.constraint_name,c.position
    Anwar

Maybe you are looking for

  • Network Drives Mapping Issue

    Hello Everyone, Since 10 days we have been facing a very different issue. A user in my company is not able to map shared drives on his Windows 7 Laptop. There are 6 windows-7 workstations having a Share in their respective c drive.  C:\ABC\xxx_share.

  • Anyone know how to change user info in logic pro 9?

    Want to know if it is possible to change the user information in logic pro 9...tried all the options in preferences and nothing...any ideas? Running on lion...

  • OJ 8500: Scan to Network Folders - invalid username/password with no password.

    I'm using an 8500 Pro Wireless (A909g) on Windows 7 machine.  I'm trying to set up the Scan to Network Folder feature. Problem is this: I dno't have a Windows password set up.  In this case, the printer cannot log onto my computer.  If I set a passwo

  • Best way to determine if document is truly unsaved

    Is there a preferred method for determining whether a file is truly unsaved? I'm distinguishing between files that have have been saved and then had some changes made to them (but have a valid name and filePath) and files that have just been created

  • I want to Use iChat with Skype to Videoconference several people

    I want to video conference in my niece in New Zealand (PC using Skype) with iChat and the rest of my Mac family stateside. I have Skype for Mac running and I have the iChat AV running. Any chance to hook in the Skype User with the iChat multi-pane vi