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?

Similar Messages

  • HT4528 My iphone is telling me I need to do a system restore and wont restart. Screen shows itunes logo and that is it. If I do this how can i avoid losing all my pictures videos etc?

    my i phone is telling me I need to do a restore. Screen shows itunes logo and thats it, even after turning off and on again.
    if  do this how can I avoid losing all my pictures videos etc?

    Pictures/Videos in your camera roll? If so, & not backed up or imported to your computer, they are gone. There's no supported way to recover them now.

  • 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 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 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

  • 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

  • I am trying to make a iphoto book but every time i click on a single photo or folder it opens up a new book. How can I avoid this? This is iphoto 10.

    I am trying to make a iphoto book but every time i click on an individual photo (or folder) it opens up a new book. How can i avoid this?

    Export the slideshow out of iPhoto as a QT movie file via the Export button in the lower toolbar.  Select Size = Medium or Large.
    Open iDVD, select a theme and drag the exported QT movie file into the open iDVD window being careful to avoid any drop zones.
    Follow this workflow to help assure the best quality video DVD:
    Once you have the project as you want it save it as a disk image via the File ➙ Save as Disk Image  menu option. This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image, launch DVD Player and play it.  If it plays OK with DVD Player the encoding is good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    If iDVD was not preinstalled on your Mac you'll have to obtain it by purchasing a copy of the iLife 09 disk from a 3rd party retailer like Amazon.com: ilife 09: Software or eBay.com.  Why, because iDVD (and iWeb) was discontinued by Apple over a year ago. 
    Why iLife 09 instead of 11?
    If you have to purchase an iLife disc in order to obtain the iDVD application remember that the iLife 11 disc only provides  themes from iDVD 5-7.  The Software Update no longer installs the earlier themes when starting from the iLIfe 11 disk nor do any of the iDVD 7 updaters available from the Apple Downloads website contain them. 
    Currently the only sure fire way to get all themes is to start with the iLife 09 disc:
    This shows the iDVD contents in the iLife 09 disc via Pacifist:
    You then can upgrade from iDVD 7.0.3 to iDVD 7.1.2 via the updaters at the Apple Downloads webpage.
    NOTE:  If you're running iPhoto 9.5 the export options will be different.
    OT

  • HOW CAN I AVOID THIS ERROR MESAGE WHILE TRYING TO EXPORT AN IPHOTO SLIDESHOW:  The operation couldn't be completed. (OSStatus error -61.)

    HOW CAN I AVOID THIS ERROR MESAGE WHILE TRYING TO EXPORT AN IPHOTO SLIDESHOW:  The operation couldn’t be completed. (OSStatus error -61.)

    Hello,
    I believe the issue was the external HD I purchased was not formatted for Mac . . . once I took care of that - all went well!  The slide show transferred and the surprise 70th birthday party was a huge sucess.  Thank you everyone!

  • I find 'plugin-container.exe' takes up 68-91% of my CPU and effectively hangs my machine; how can I avoid this, from happening?

    I find 'plugin-container.exe' takes up 68-91% of my CPU and effectively hangs my machine; how can I avoid this, from happening?

    You can disable the plug-in container for one or two plug-ins, or for all the plug-ins it works for. <br />
    http://kb.mozillazine.org/Plugin-container_and_out-of-process_plugins

  • I have photos I want to group together in one album, but can't do this because some may have the same number. How can I combine them all into one album?

    I have photos I want to group together in one album, but can't do this because some may have the same number. How can I combine them all into one album? I was trying to move several albums onto a USB drive and it stated all other files exist at this location.  They are pictures taken at different times and have the same number I guess.

    In iPhoto albums may contain photos with the same file name - iPhoto handles that just fine
    If you are exporting them to move somewhere else use the sequential file name feature of export to give each file a unique name
    LN

  • I cannot locate my cs6 redemption code and I just purchased a new computer because my old one doesn't work anymore. How can I get my photoshop on this computer? All my other products are registerd with a serial number

    I cannot locate my cs6 redemption code and I just purchased a new computer because my old one doesn't work anymore. How can I get my photoshop on this computer? All my other products are registerd with a serial number

    The activation servers for CS and CS2 stopped working and were taken down. You'll need to take a look at this link for your issue: https://helpx.adobe.com/x-productkb/policy-pricing/creative-suite-2-activation-end-life.ht ml
    Benjamin

  • HT1766 My ipod 4g keept crashing so then i read on this website to go to settings and rest everything. And when i did everything on my ipod got deleted.I tried restarting it but i didnt restore my ipod before everthing got erased. How can i get it all bac

    My ipod 4g keept crashing so then i read on this website to go to settings and rest everything. And when i did everything on my ipod got deleted.I tried restarting it but i didnt restore my ipod before so everthing got erased. How can i get it all back???

    Restore from backup if you have one:
    To restore from backup see:
    iOS: Back up and restore your iOS device with iCloud or iTunes       
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

  • When I create an email signature, the text I type is repeated twice in the actual email sent (above and below a line).  How can I avoid this?

    When I create an email signature, the text I type is repeated twice in the actual email sent (above and below a line).  How can I avoid this?

    Try validating your installed fonts and fixing any errors that show up. To do this see this article: http://reviews.cnet.com/8301-13727_7-20085570-263/safari-in-os-x-lion-replacing- text-with-block-a-characters/

  • I have some chrages on my debit card by error how can i avoid this charges

    i have some charges in my debit card by error how can i avoid this charges.... i reset my password as an email said with that resert the charges won´t be reflected in my account?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

Maybe you are looking for

  • Using Cursor and FOR LOOP to INSERT the data into table

    Hi all, I have SELECT statement that returns 3 rows: PROCESSNAME PROTDATE IMM 2013-12-18 Metrology 2013-11-18 CT 2013-12-04 SELECT  processName, MAX(NVL(protStartDate, protCreateDate)) AS protDate     FROM TABLE(SEM_MATCH("{             ?ipc rdf:type

  • Bridge CS6 no inicia camera raw

    hola, tras el cambio del sistema operativo de windos xp a windows 7 (no lo hice yo, no se como reinstalaron los programas), Bridge dejó de abrir camera raw y ajustes de color de la suite, arroja un error que dice que "la aplicacion bridge principal n

  • Screen doesn't display anything. GT70

    Me as a few other I have seen on the forum is having the problem were the laptop simply refuses to use anything but the Intel HD 4000 video card. I tried several different maximum performance settings to no success. I went into my device manage and d

  • Invalid Index in Web Report

    Post Author: mhamill CA Forum: .NET I have a report which is being published and viewed on the web via a CrystalReportViewer app to display the reports (.rpt files)All other reports are running fine. When I run this new report in Crystal on my deskto

  • Line after  text in smartforms display

    Hi , Issue 1: I want to display a line after a text. Ex: Name _______________________________________ I am unable to display the line till the end of the page. When I save and activate, the line gets shortned itself as below.      Name ______________