Please help me with the Alternative of queries to replace the UNION ALL for two queries

Hi all

I have the query to retrieve assets employees salary count and in so far as below:

Select ename, emp_no, sum (sal_till_2010), sum (sal_till_2014) of

(select emp_no, ename, salary as sal_till_2010, 0 as sal_till_2014 of employee e1

where effective_date < = 1 January 2010 ' and not exists (select 1 from e2 employee_deletion where e2.emp_no = e1.emp_no and e2.deletion_date < = January 1, 2010 "")

UNION ALL

Select ename, emp_no, 0 as sal_till_2010, salary as employee e1 sal_till_2014 - here is a dummy 0 salary until 2010 for the union of all the

where effective_date < = 1 January 2014 "and not exists (select 1 from e2 employee_deletion where e2.emp_no = e1.emp_no and e2.deletion_date < = 1 January 2014") "

Group of emp_no, ename;

In this query, I get the total salary until 2010 and until 2014 in the employee table, dates are dynamically passed to the procedure, and this can change.

But assume the date above and let me know the alternative of queries to improve performance because I use Union ALL and read the same table twice in the above query.

Advice me with request to read the table once to fetch the same data as the above query.

Thanks in advance.


Hello

Thanks for the display of the data of the sample; It's very useful!

I think OP wants something like this:

WITH cutoff_dates AS

(

SELECT TO_DATE (January 1, 2010 ', ' DD/MM/YYYY') AS cutoff_date, 2010 UNDER the label OF dual UNION ALL

SELECT TO_DATE (1 January 2014 ', "DD/MM/YYYY"), double 2014

)

SELECT e.emp_no, e.ename

, NVL (SUM (CASE WHEN c.label = 2010 THEN e.salary END), 0) AS sal_till_2010

, NVL (SUM (CASE WHEN c.label = 2014 THEN e.salary END), 0) AS sal_till_2014

E employee

JOIN cutoff_dates c ON e.effective_date<=>

WHERE DOES NOT EXIST)

SELECT 1

Of employee_deletion ed

WHERE ed.emp_no = e.emp_no

AND ed.deletion_date<=>

)

E.emp_no GROUP, e.ename

ORDER BY e.emp_no

;

Output of your sample data:

EMP_NO ENAME SAL_TILL_2010 SAL_TILL_2014

---------- ------ ------------- -------------

1 Mickey 450 0

2 Donald 750 0

Tags: Database

Similar Questions

  • Can you please provide me with the part number for the screen for model #: NX. SHKAA.001?

    Can you please provide me with the part number for the screen for model #: NX. SHKAA.001 (AO1 - 131 M-C1T4)?  The first ten digits of the serial number are NXSHKAA005.

    Matt or gloss is what it looks like. Some like not brilliant but because most are a reflection. I would say that they would work as long as the resolution of the size and the backlight are the same.

  • Please help me with the issue of the image

    Hello

    I need to create a report of error log which two same named images overlapped together.

    Screen Shot 2015-12-16 at 1.01.06 PM.png

    The image above shows how is my page indesign file. I need the report as error log:

    With overlapping of images: photo_sample3.jpg

    Logic:

    I don't know what logic I need to use to get there. But with my knowledge, I thought, I can use the image name and the value of geometric image to achieve. I found a script that gives the number duplication, if any of this page in this page of this forum.

    var overlapArray = new Array();  
    var myPages = app.activeDocument.pages.everyItem().getElements();  
      
    for(i=0; i<myPages.length; i++)  
    {  
        var myPgItems = myPages[i].allPageItems;  
        for(k=0; k<myPgItems.length; k++)  
        {  
         var bounds1 = myPgItems[k].geometricBounds;  
                for(j=0; j<myPgItems.length; j++)  
                     {  
                       var bounds2 = myPgItems[j].geometricBounds;  
                         if(k==j)  
                         {  
                             continue;  
                         }  
                        var temp = touches(bounds1, bounds2);                     
                        if(temp == true)  
                        {  
                            overlapArray.push(myPages[i].name)  
                        }  
                 }  
             }  
     }  
    alert("overlap Pages: "+overlapArray);  
      
    function touches(bounds1, bounds2)  
    {  
    if (bounds1[2] < bounds2[0]) return false;  
    if (bounds1[0] > bounds2[2]) return false;  
    if (bounds1[1] > bounds2[3]) return false;  
    if (bounds1[3] < bounds2[1]) return false;  
      return true;  
    }   
    

    Please help me with script or logic.

    Thank you in advance,

    Kitty

    Hi well,.

    all was needed was a line of code

    Array.prototype.intersect = function ( coordinates ) {
        var n = this.length;
        var nY1, nX1, nY2, nX2;
        var y1 = coordinates[0];
        var x1 = coordinates[1];
        var y2 = coordinates[2];
        var x2 = coordinates[3];
    
        while ( n-- ) {
            nY1 = this[n][0];
            nX1 = this[n][1];
            nY2 = this[n][2];
            nX2 = this[n][3];
    
            if (
                (
                    ( y1>=nY1 && y1<=nY2 )
                    &&
                    (x1>=nX1 && x1<=nX2 )
                )
    
                ||
    
                (
                    ( y2>=nY1 && y2<=nY2 )
                    &&
                    (x2>=nX1 && x2<=nX2 )
                )
    
            ){
                return true;
            }
        }
    
        return false;
    }
    function reportOverlaps() {
        var doc,gs, g, n, o = {}, p, pg, pb, lk, lkn, overlaps = [];
    
        if (!app.documents.length) return;
    
        doc = app.activeDocument;
    
        gs = doc.allGraphics;
    
        n = gs.length;
    
        while ( n-- ) {
            g = gs[n];
            p = g.parent;
            pg = p.properties.parentPage;
            if ( pg instanceof Page ) {
                pb = p.visibleBounds;
    
                lk = g.itemLink;
                lkn = lk.name;
    
                if ( !o[pg.name] ) {
                    o[pg.name] = o[pg.name] || {};
                }
    
                if ( !o[pg.name][lkn] ) {
                    o[pg.name][lkn] = o[pg.name][lkn] || [];
                    o[pg.name][lkn][ o[pg.name][lkn].length ] = pb;
                }
                else {
                    var intersect = o[pg.name][lkn].intersect ( pb );
                    intersect && overlaps[ overlaps.length ] = "Pg:"+pg.name+"//"+lkn;
                    o[pg.name][lkn][ o[pg.name][lkn].length ] = pb;
                }
            }
        }
    
        alert( overlaps.length? "Following overlaps where found:\r"+overlaps.join('\r' ) : "No overlaps found" );
    }
    
    reportOverlaps();
    

    Loïc

    www.ozalto.com

  • Please HELP me with the problem I encountered with ' Microsoft did-It ' ~ it has stopped working and displated this (?) ;-2147023080 error code

    I am a simple user of PC with Windows XPI downloaded ' Microsoft did-It ' and have used it successfully several times until today.

    Earlier today, it simply stopped working in the middle of his analysis or whatever and posted the following to the value of the figures & numbers    ;-2147023080

    Is it a CODE of ERROR or something?  How can I solve this please?

    ALSO:  I also got another code (or whatever you call) showing following error (0 x 0) unk

    Can someone help me understand this?

    When I went through the trouble of looking up for the first time for a "fix", good old MVP "STEVE" led me to a sales PITCH for some DRIVERS REPAIR download I had to ENROLL in the first, while THEY WANTED ME to PAY THEIR MONEY BEFORE HELP me

    Sincerely grateful for your help.

    Sherry

    Hi Sherry,

    Can I know what question faced you that prompted, allowing you to run the Fixit?

    The question you posted would be better suited in the Forums of Microsoft Fixit. I would recommend posting your query in the link below.

    http://social.Microsoft.com/forums/en-us/fixitcenter/threads

    Good day!

    Answer please if you have any questions.

  • Please help me with the video card and power supply issues!

    Hello and thanks in advance for any help. I'll try and do a short explanation, but I can't promise anything. I bought an a6620f Pavilion about 2 months ago I didn't know that you had to purchase a special hardware in order to play video games. In any case, I bought about 300.00 worth of new video games and none of them works. they say because of my video card. Then try to buy a new video card and it won't work because I only have a 250 watt power supply. I spoke with a hp technician before you buy a PSU and I was told that my motherboard was only designed to use a 300 watt max power I tried to buy one at best buy and the clerk said 4500 is the smallest they sell. and I need at least a 400 Watt or powerrsupply to make the new video card with a value of buyiong. My questuion is what can I do if I can't buy one more big power supply how can I install a new video casrd? Please help me I'm lost

    Oh and in case you want some specs on my system here are a few

    Windows Vista Home premium service pack1
    HP Pavilion a6620f
    Processor: pentium dual core cpu e5200 @ 2.50 GHZ
    memory: 4.00 GB
    system type: 64-bit operating system
    Version of DirectX 10
    graphics card: intel GMA 3100 Total memory 256 MB

    Message edited by chefinomaha on 06/03/2009 16:38

    Hi chefinomaha,

    Sorry to hear about your frustration. Here's some good news.

    I think you have been misinformed or there was a communication error. Your motherboard should not be limited to the only 300W. I don't know with certainty how high you can go in watts, but you can go higher and should go higher, if you add a video card.

    The important thing is to get the right kind of diet that fits your connectors.

    Here's your motherboard page.

    Here is a document with step-by-step instructions and video for adding a video card.

    Here is a document with the video to replace the power supply.

  • Please help, problem with the creation of PDF

    Please help me, this message keeps showing on the 3rd page of a PDF document I have to build:

    Please wait... If this message is not subsequently replaced by the good content of the document, your PDF reader isn't able to display this type of document. You can upgrade to the latest version of Adobe Reader for Windows®, Linux® or Mac by visiting http://www.adobe.com/go/reader_download. For more assistance with Adobe Reader, please visit http://www.adobe.com/go/acrreader.

    Adobe reader is already up to date

    It sounds like it may be related to create forms in LiveCycle. Here is another discussion on the issue of the forum LiveCycle error: "If this message is not finally replaced by appropriate... content." »

  • Please help me with the download of lightroom.  I bought adobe online, but its not downloading

    Please help with the download of lightroom.  I bought adobe online, and it is not downloading.

    If you follow the 7 steps (here, http://prodesigntools.com/all-adobe-cs5-direct-download-links.html) you can dl a free trial here: http://prodesigntools.com/lightroom-5-ddl-comparison-vs-lr4.html

    and activate it with your serial number.

    If you have a problem dl'g, you don't follow all 7 steps.  the most common mistake is not meticulously follow the steps 1, 2, and/or 3 (which adds a cookie to your system, allowing you to download the correct version of the adobe.com site).

  • Someone please help me with the installation of an updated on my Blackberry browser

    When I access windows live on my windows (9330) BlackBerry curve says I need an upgraded browser to use windows live. Internet Explorer is not available for Blackberry. What am I supposed to do at this point? Please help me and if possible send me your opinions and or solution. * E-mail address is removed from the privacy *

    Hi TimHayner,

    I suggest you to contact Blackberry support for more help and information.

    http://us.BlackBerry.com/support/

  • Please help me with the custom text field FormCalc

    There is someone online has done a very good thing for me - they helped me create a text field that would be of type 'this document has been printed on _' and include some day the pdf was printed on the employer's intranet site.

    I had a shortcut in my favorites and would click on it and place it on each new document that I needed on.

    Because the computer I was using suddenly fell down, can't get the details of how to set it up again. I have a pdf form that includes the box, but when I open it in LiveCycle, it's just empty.

    That's what I saved:

    < field h = mm "8,4935" name = "PrintedOn" w = "141,0398 mm" x = "-0,0001 mm" y = "0 mm" xmlns ="http://www.xfa.org/schema/xfa-template/2.5/" > ""
    < ui >
    < textEdit >
    < border hand = 'right' presence = "hidden" >
    <? templateDesigner styleId aped0? > < / border >
    < margin / >
    < / textEdit >
    < /UI >
    < police size = cast "18pt" = "Tahoma" weight = "bold" >
    < filling >
    < color value = "221,221,221" / >
    < / filling >
    < / make >
    < para hAlign = "center" vAlign = "middle" / >
    < link match = "none" / >
    < activity = "prePrint" ref = "$host" >
    < script >$ .rawValue = concat ("this document has been printed on:", num2date (date (), DateFmt (1))); < /script >
    < / event >
    < / field >

    I don't remember what to do to get this working.

    I use this text box "print on" ALL the time, and I need to know what to do to get back to work quickly.

    If there is someone who could help me, I could also send you a sample of a form which includes it - so you can see exactly what I mean.

    If someone could remember how to program this kind of thing in once again and save it in LiveCycle, then explain how I can put it on another computer so I'd really, REALLY appreciate it.

    ~ Chris

    PS - this one as I had put in place only prints print message per day on the first page. If she could somehow print on EACH page of the PDF file without me having to click and add it to each page individually, it would be better... but let's first!

    Hello

    The script is here. If you place a new textfield in the Master Page and put the following script in the event of pre-publication of the field:

    $ = concat("This document was printed on: ", num2date(date(), DateFmt(1)))
    

    The language is FormCalc.

    Please note that you don't need to go to the XML Source for this. Simply select the textfield object and open the Script Editor (in the Windows menu). Drag the bottom of the editor bar so that you can see a few lines, and then set the FormCalc language.

    Should work,

    Niall

  • Please help me with the miniatures in pdf format

    Hi, I need help to see the thumbnails generated in PDF format. I have a very very large number of eBooks in the format PDF to work and study.  and all of a sudden I can't look at the generated thumbnails, only the icon of adobe, do me impossible to find a specific book.

    If I give, double-click the book opens normally and I can't reed as ever.

    Help, please! is very important for me its my way of life and work.

    Help.

    Read this:

    http://forums.Adobe.com/thread/303008?TSTART=0

  • Please help me with the missing right parenthesis

    The code below gives me error of missing right parenthesis. can someone help me understand the error code. Thank you.

    SELECT * FROM CIRC.DRAW_TYPE A
    WHERE A.CITY_CODE IN CASE WHEN :Rnzip='WithZip' THEN   ('46301', '46302') ELSE  A.CITY_CODE END

    You can try this.

    SELECT *
      FROM CIRC.DRAW_TYPE A
     WHERE (A.CITY_CODE = decode(:Rnzip,'WithZip','46301',A.CITY_CODE))
        Or (A.CITY_CODE = decode(:Rnzip,'WithZip','46302',A.CITY_CODE))
    

    Note: not tested

  • I use Adobe Acrobat DC and you want to get off at Acrobat XI. Please help me with the procedure. Thank you

    Hello

    I use Acrobat DC and want to upgrade it to Acrobat XI. What is the procedure so that I can use the same serial for Acrobat XI key. Waiting for your response. Thank you

    You can not. You need a key to series made for XI. These are no longer sold.

  • HP 15-ac025tx: Please help to find the right driver for Wi - Fi and Bluetooth

    HP 15-ac025tx

    MODEL: M9V00PA #ACJ

    OS: Windows 7 (64-bit)

    Hello

    Would you be able to help with the link to the drivers for my laptop model mentioned above.

    1 WiFi

    2 Bluetooth

    3. the screen

    These are the elements located in the exclamation point (!) in the Windows Device Manager:

    -Graphics cards

    AMD Radeon (TM) R5 M330

    -Other devices

    BCM43142A0

    Network controller

    Acquisition of ICP data and Signal Processing controller

    Unknown device

    Many thanks in advance,

    Anish

    New Delhi

    Hello:

    You need these drivers for the wireless and bluetooth...

    http://h20564.www2.HP.com/hpsc/SWD/public/detail?sp4ts.Oid=6943827 & swItemId = ob_145419_1 & swEnvOid = 4058

    http://h20564.www2.HP.com/hpsc/SWD/public/detail?swItemId=ob_154511_1

    Graphics card: first install the Intel driver and restart.

    This package provides the driver that allows graphics Intel high definition (HD) in the notebook models that are running an operating system supported. If the video output high-definition multimedia interface (HDMI) is supported, this package also installs the HDMI Audio Driver.

    File name: sp72651.exe

    Then, install the graphics driver amd and restart.

    This package provides the graphics driver AMD/Intel switchable high definition (HD) for models of laptop computers that are running an operating system supported. For laptops equipped with switchable graphics modes, this package contains the drivers for the two graphics (GPU). Switchable graphics allow users to switch between a graphical power mode (normally used under the power of the battery) and a mode of graphics performance.

    File name: sp71254.exe

    Acquisition of ICP data and Signal Processing controller:

    This package contains the driver which allows Intel platform dynamic and thermal firmware setting. Intel platform dynamic and thermal environment information system temperature and power use for the thermal protection of the system to work properly. This package is provided for the laptop models running a supported operating system.

    File name: sp71262.exe

    Unknown device is probably in need of this driver...

    This package provides the HP 3D DriveGuard software (HP ProtectSmart Hard Drive Protection) for the laptop models running a supported operating system. HP 3D DriveGuard software protects the drive hard by parking the heads if cell phone accidentally falls, or is suddenly struck by another object.

    File name: sp71811.exe

  • Please help me with the DRIVERS. [HP pavilion dv900/dv9500/dv9605ea]

    Right. Hello guys!

    I did a downgrade, and while the XP installation went well. I can't get the correct drivers necessary.

    Looking at the HP computer, it says "HP Pavilion dv9000"on the upper right side of the screen. However, on the underside of the laptop if there is the following information:

    "Product: HP pavilion dv9500 .

    Serial number XXXX XXX x

    P/n 959EA #ABU GZ

    "Maintain the label: dv9605ea"

    I tried all the drivers for each of these sets, but they all seem to be evil.

    In the Device Manager, all deivces in 'Other devices' do not work - I know that this is due to the lack of driver. [Audio processor co, ethernet controller, devide bus High definition Audio, device modem on high definition audio, sm bus controller and video controller bus]

    Now my question is this - where can I get the right drivers I am after please? What model number is also my pc exactly?

    Moreover, mine comes with an Amd 64 athlon X 2 and Nvidia graphics [driver for Nvidia graphics required too please]

    I would appreciate your help please. I didn't know that decommissioning will be this much pain.

    Thank you.

    Message edited by BlaQQue on 30/05/2009 06:52
    Message edited by BlaQQue on 30/05/2009 07:20
    Message edited by BlaQQue on 30/05/2009 09:08

    Drivers:

    Drivers for your model:

    Chipset here (first install it and reboot)

    MS-UAA (a reboot before the Audio and graphics driver is required) here

    NVIDIA graphic 7150 M   here

    Conexant HD Audio here

    Conexant HD AUDIO Soft Data Fax Modem with SmartCP Driver here

    Broadcom wireless here

    .NET framework (required before HP Quick Launch Buttons) here

    HP Quick Launch buttons here

    Ricoh 5-in-1 card reader here

    Synaptics Touchpad here

    CyberLink YouCam software here

  • Please help me with the mouse over event on this clip

    I'm doing a view in flash box that slides out toward the right and opens on the mouse.

    I did the necessary actionscripting, according to me, and yet the clip quite does not properly

    Can someone help me please

    I included a link to download the .fla file because it won't let me attach here with this post by saying "the content of this attachment type is not allowed."

    http://rapidshare.com/files/258224416/slider.Fla.html

    Thanks in advance,

    ELBEE.

    {run}
    _parent. Play();
    }

Maybe you are looking for

  • iTunes version 12.3.3 used to synchronize with the iPhone 6

    I installed the update to iTunes (Version 12.3.3) on my MacBook Pro. However - now iTunes won't sync with my iPhone 6. The color wheel continues to turn but will not connect with my iPhone. My iPhone and MacBook have all proposed updates. And work we

  • Cannot locate the entry point in msvcrt.dll

    During the installation of my program (created with LabWindows 'Building Distribution') on a specific computer, I get the following error: "The point_except_handler4_common of procedure not found entry into the dynamic link library msvcrt.dll." I und

  • How to reduce a picture to the email

    I have pictures in my photo gallery and I'm trying to e-mail on craigslist. They say trying to downsize if it takes to long. Well, how can I do? Thank you

  • Windows startup errors

    I just got a few errors at the Windows startup. The first says "Windows cannot load the locally stored profile. Possible causes include insufficient security rights or a damaged local profile. "The second says" Windows cannot find the local profile a

  • Pavilion dv6 Notebook: laptop still does not start if equipped upward of battery

    Pavilion dv6 daughter Notebook always primer not beyond the screen HP enrobeur battery if Product number: WR498EA #ABUSerial number: [personal information deleted] Operating system: Windows 7