Alternative for EXISTS for this problem

Hello

create the table test_pa
(number of emp_id,
run_date date,
Number value,
Run_type varchar (1)
);

insert into test_pa values (1, trunc (sysdate), 500,' a);
insert into test_pa values (1, trunc (sysdate), 400,' a);
insert into test_pa values (1, trunc (sysdate), 300,' it);

insert into test_pa values (2, trunc (sysdate), 500,' a);
insert into test_pa values (2, trunc (sysdate), 400,' a);
insert into test_pa values (2, trunc (sysdate), 300,' a);

insert into test_pa values (3, trunc (sysdate), 500,' it);
insert into test_pa values (3, trunc (sysdate), 400,' it);
insert into test_pa values (3, trunc (sysdate), 300,' a);

commit;

Now, I want to display all the records for these employees on a special day in which the employee had a performance of 'C '. So in this example, I want the release of records for emp id 1 and 2.

The query I use is

Select * from test_pa a

where exists (select 1 from test_pa b where a.emp_id = b.emp_id and a.run_date = b.run_date and b.run_type = "C");

This works as expected. However, this is a test table and the original table on which I want to apply this million lines. My question is if there is a better alternative EXISTS to improve performance. This query takes a long time to run on the original table.

Thank you

Hello

So, to decide if a line should be included or not, you need to look at other lines.

An EXISTS subquery is a way: to do.

Analytical functions, IN questioning him and other ways self-joins.

Here's how you can use the analytic function MAX:

WITH got_ok_flag AS

(

SELECT emp_id, run_date, value, run_type

MAX (CASE

WHEN run_type = 'C '.

THEN 1

END

) OVER (PARTITION BY emp_id) AS ok_flag

OF test_pa

-WHERE... - If you need any filtering, put it here

)

SELECT emp_id, run_date, value, run_type

OF got_ok_flag

WHERE ok_flag = 1

ORDER BY emp_id

;

Dependning on what you mean by "on a special day", you need to maybe add a WHERE clause, or change the PARTITION BY clause analytical.

Tags: Database

Similar Questions

  • I have the latest version of Firefox are installed (which has been updated), but the site says that it is the older. Is there a solution for this problem?

    I have the latest version of Firefox are installed (which has been updated), but the site says that it is the older. Is there a solution for this problem?

    You have a corrupted user agent which identifies you like Firefox/3.0.11

    • Mozilla/5.0 (Windows; U; Windows NT 6.1; UK; RV:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 WebMoney Advisor

    See:

  • My book pro 15 Mac since April 2014 retina does not work because of problem of logicboard, and without any reason. Fact it is passed to one of you so early? Do you know something about any recall for this problem?

    My book pro 15 Mac since April 2014 retina does not work because of problem of logicboard, and without any reason.  Fact it is passed to one of you so early? Do you know something about any recall for this problem?

    There is no repair program from Apple for any 2014 Mbit/s at the moment.  Have you taken your MBP to a store for a FREE Apple genius bar?

    Ciao.

  • Why iPod nano 7th generation does not support Khmer language? New update for this problem please Apple release?

    Why iPod nano 7th generation does not support Khmer language with the latest version 1.1.1? Apple could release a new update for this problem?

    I am from Cambodia, I love Apple products, so I need Khmer language with all Apple devices!

    Thank you!

    For Apple to see your application, you should repost it to

    http://www.Apple.com/feedback

  • I have a toshiba laptop purchased recently. After the scheduled updates it does not recognize the wireless network. I have to do a system restore. is there a solution for this problem?

    I have a toshiba laptop purchased recently.  After the scheduled updates it does not recognize the wireless network. I have to do a system restore.  is there a solution for this problem?

    Hello

    Make sure you have the latest network adapter drivers fron toshiba

    http://www.CSD.Toshiba.com/cgi-bin/TAIS/support/JSP/home.jsp

    and if windows update is at the origin of the problem change how to get updates to uncover the problem update

    When you have found the issue, a right click on it then invited uac then hide

    read the information on the link below

    http://www.bleepingcomputer.com/tutorials/tutorial140.html

    Download updates but let me choose whether to install them - if you select this option, Windows will download the updates on your computer, but not install them automatically. If you want to install updates, then you must install them manually. You should only select this option if you have a reason to not install updates automatically. Only advanced users should use this option.

    Check for updates but let me choose whether to download and install them - if you select this option, you'll be alerted when there are new updates available for download and install. You can then choose to download and install the updates that you want. This option should really be reserved for people who know exactly which updates they need, or those who have little access to the Internet.

  • When I turn on the system of its display in the moniter as NTLDR missing.please give me the solution for this problem.

    When I turn on the system of his displayiing on the moniter as NTLDR missing. Please give me the solution for this problem

    Hello

    NTLDR is not used for installation of Vista, it's a vestige of WinXP / 2K. If it is listed as "missing", then your boot sector is damaged and must be repaired. The steps are described here: http://support.microsoft.com/default.aspx/kb/927392?p=1

    Good luck, Rick Rogers, aka "Crazy" - Microsoft MVP http://mvp.support.microsoft.com Windows help - www.rickrogers.org

  • Google Chrome has stopped working correctly, for this problem can do

    Google Chrome has stopped working correctly, for this problem can do

    Event Viewer reports

    1. normally, when an error occurs on your computer looking in Event Viewer should be your starting point to find a solution. More related system errors are recorded and get an exact copy of the relevant report is important. Unfortunately, is not easy to understand reports and most of the users computer need help with their interpretation. I have to say later interpretation.

    2 Event Viewer includes three main newspapers of Windows. Here's the Application, security, and system. For purposes of troubleshooting system is by far the most important.

    3. to access the system log, select Start, Control Panel, administrative tools, Event Viewer, in the list on the left of the window select Windows and the system logs. Place the cursor on the system, right click and select filter current log. Check the front of the error and click OK and see you only reports errors. Click the Date and time column header to sort. You may need to click a second time to see the last report above.

    4. a tip for posting copies of error reports! Run Event Viewer and double-click the error you want to copy. Click the copy button to place a copy in the Clipboard and close Event Viewer. Now start your message and paste it into the body of the message. Make sure that it is the first dough right out of the event viewer.

    5. He cautioned against three types of reports, information, and reports errors. In most situations, it is the error reports that offer the best information but sometimes WARNING reports provide useful clues.

    6. all reports have stamps date and hour and when troubleshooting, it is important to focus on the latest reports. Reports of studies from the point when the computer is started, and then check if a similar report appeared in the previous session. If errors do not repeat investigation as to why they happen is wasted effort.

    7. in the individual reports the most important information is the event ID and Source such as these help when looking for help on the internet. The description is just as important and copy the exact text to use as search criteria greatly helps achieve better results when using Google. Not paraphrase descriptions when other people asking for help.

  • I have panasonic lumix g6 and cannot open raw with adobe elements 12 files, there is no support for this problem, any suggestions?

    I have panasonic lumix g6 and cannot open raw with adobe elements 12 files, there is no support for this problem, any suggestions?

    Did you check help-> updates to see if they are available? You probably don't have the latest version of Camera Raw that was compatible with Photoshop elements 12 installed.

  • Premiere Pro is mess up my audio/video synchronization. Use Handbrake really the only solution for this problem?

    Premiere Pro is mess up my audio/video synchronization for the images that I downloaded from my iPhone 6 s + (.) MOV files). The files play fine, but once that I put them in Premiere Pro, the audio falls slowly behind the video, probably to cause "variable frame rate." phone I've seen other threads where people had the same problem, and the universal response, I saw was freeware download called 'Handbrake' to convert the frame rate of variable to fixed... but is not sit right with me.

    Uses 3rd party freeware really the only solution for this problem? Video editing software Adobe Professional-grade not really have the ability to solve this problem? If so, what should I do to prevent all Premiere Pro ruin all my pictures to import?

    Hi Christafarian,

    Premiere Pro is mess up my audio/video synchronization for the images that I downloaded from my iPhone 6 s + (.) MOV files).

    You wouldn't be the first. I'm sorry.

    The files play fine, but once that I put them in Premiere Pro, the audio falls slowly behind the video, probably to cause "variable frame rate." the phone

    I found:

    • If you pull the iPhone in a well-lit environment, it records at a constant speed.
    • In lighting challenged environments, you get images image variable rate.

    I've seen other threads where people had the same problem, and the universal response, I saw was freeware download called 'Handbrake' to convert the frame rate of variable to fixed... but is not sit right with me.

    For this project, you're probably stuck with transcoding with Handbrake or another method not Adobe. Our coders simply do not handle variable frame rates.

    Uses 3rd party freeware really the only solution for this problem?

    With Premiere Pro and this project, you have no other choice. For future projects, look into purchasing a high end video camera application where you can shoot at a constant rate regardless of the stage lighting.

    Video editing software Adobe Professional-grade not really have the ability to solve this problem? If so, what should I do to prevent all Premiere Pro ruin all my pictures to import?

    If you like Premiere Pro to support variable frame rates, please create a feature request. Otherwise, I hope my tips will help you in the future.

    Thank you
    Kevin

  • The content of my site is misplaced and shrunken Apple desktop devices. The browser provides information on devices, but the content do not place nor scale properly. The reason for this problem would be failure to adjust the size of the browser in Muse? I

    The content of my site is misplaced and shrunken Apple desktop devices. The browser provides information on devices, but the content do not place nor scale properly. The reason for this problem would be failure to adjust the size of the browser in Muse? I conceive on a 23 inches HD Windows desktop base. My site is displayed as it should, except on Apple desktop devices.

    This may depend on several things as if contents are pinned, scrolling is applied etc.

    Try to resize the browser preview in the Muse for verification, site url will help you to study.

    Thank you

    Sanjit

  • right to sentences overturned left from left to right in pdf to excel export... you have a solution for this problem?

    I found a problem when converted from pdf to excel in Arabic or Hebrew, it gives me the right sentences overturned left from left to right...

    you have a solution for this problem?

    Known problem (I submitted the bug a few years report - also applies to export to Word, PowerPoint, etc.) for that (unfortunately) there is not yet a date, release or resolution plan.

    -Dov

  • Adobe Photoshop Lightroom 6.2 update for Mac OSX is OUT suspended bij! I hope that Adobe will soon have a hotfix update for this problem?

    Adobe Photoshop Lightroom 6.2 update for Mac OS x is by hanging OUT! I hope that Adobe will soon have a hotfix update for this problem.

    Hi all

    6.3/CC 2015.3 Lightroom is now available - try to update to this version which includes the previous import feature, bug fixes and new support for photo/target device profile: Lightroom CC 2015.3 / 6.3 now available

    Concerning

    Pete

  • Can someone solve or give me a solution for this problem...?

    Hello world!

    Can someone solve or give me a solution for this problem...?

    We used two folders Source & Finalwork. We get image Source folder and path of silo put & moved to Finalwork folder.

    Is it possible to check if the two colors of Embedded images folder profile identical or not.

    -yajiv

    Could you elaborate what you mean by that

    We get image Source folder and path of silo put & moved to Finalwork folder.

    Perhaps with a screenshot to illustrate the task?

    // 2012, use it at your own risk;
    #target photoshop
    var theFolder = Folder.selectDialog ("select source folder");
    if (theFolder) {
    var theFiles = theFolder.getFiles(/\.(jpg|tif|eps|psd)$/i)
    };
    var theOtherFolder = Folder.selectDialog ("select target folder");
    if (theOtherFolder) {
    var theOtherFiles = theOtherFolder.getFiles(/\.(jpg|tif|eps|psd)$/i)
    };
    var missingFiles = new Array;
    var unmatchedProfiles = new Array;
    // work through files;
    for (var m = 0; m < theFiles.length; m++) {
              var check = false;
              var theFile = theFiles[m];
    // find name of the same name;
              for (var n = 0; n < theOtherFiles.length; n++) {
                        var theOtherFile = theOtherFiles[n];
    // if one is found;
                        if (theFile.name == theOtherFile.name) {
                                  check = true;
                                  var oneFile = app.open(File(theFile));
                                  var otherFile = app.open(File(theOtherFile));
    // check profiles;
                                  if (oneFile.colorProfileName == otherFile.colorProfileName) {
                                            }
    // collect umages with unmatched profiles;
                                  else {unmatchedProfiles.push(theFile)};
                                  };
                        };
    // collect missing files;
              if (check == false) {alert ("hahaha");missingFiles.push(theFile)}
              };
    // alert of problems;
    if (unmatchedProfiles.length > 0) {
    alert ("the corresponding files for these do have a different color space:\n"+unmatchedProfiles.join("\n\n"));
    };
    if (missingFiles.length > 0) {
    alert ("these files miss corresponding ones:\n"+missingFiles.join("\n\n"));
    };
    //////
    ////// get psds, tifs and jpgs from files //////
    function getFiles (theFile) {
        if (theFile.name.match(/\.(jpg|tif|psd|pdf|)$/i)) {
            return true
            };
              };
    
  • I have a Toshiba laptop and when I turned to go to the line that appeared CfFnc catalyst is not dose of work someone at - it a solution for this problem

    This problem is me slaughter of the games through windows, I think that someone can give me an idea to solve this problem.

    CfFnc is Toshiba support application to allow you to connect to wireless networks.  Have nothing to do with you a game if it does not work unless the game was on a website and you could not get on the Internet at all.  In this case, you do not want to ask for help from the Toshiba support as to why the application crashes.  In the end, it shouldn't be your games do not work.

  • Password blackBerry Smartphones does not satisfy the requirements of duration for this problem domain in the creation of BlackBerry ID

    I am developer form India. Im trying to create my BlackBerry ID of the past 5 days. Each time that its giving me same error

    Password does not meet the requirements of length for this field. I'm really frustrated.can anyone solve this problem?

    Thank you

    Ok. Let's start with: how many characters you use the password?

    I don't remember the minimum number of characters in the password, it might be six, but why not try using a password with 6, I know full well that work of 8 characters.

  • My date/time settings mobile keep returning to time and dates in the past frequently, is there a fixx for this problem?

    My Lenvo V570 keeps returning to different dates/time in the past, and he is only 6 months old? It has Windows 7 64 bit os. At an i5 QuadCore Intel processors inside. Is there a software fix or patch to stop this problem?

    Lisa,

    A low CMOS battery can sometimes various issues, including slow, locking unexplained performance issues as well as others.

    It is quite rare, but the battery is relatively easy to replace, check the manual of your computer/motherboard for replacement details.

    Generally, the battery is a watch battery "CR2032", about the size of a nickel.

    I have yet to see a laptop whose battery is easy to replace...

    Here is a simple test to check if the battery needs to be replaced:

    1. Start the computer in Mode without failure.
    2. Set the date and time.
    3. Stop the machine.
    4. Remove the battery from bit and disconnect the machine from the sector.
    5. Wait at least 24 hours.
    6. Start the computer in Mode without failure.
    7. Check the date and time.
    If the time is incorrect then you are probably dealing with a flat battery from motherboard. You will probably get the machine to replace unless you have good skills in disassembly of electronic components.

Maybe you are looking for

  • Reset my router & get a DNS error?

    Why do keep losing the connection to the internet and have too keep resetting my router & get a DNS error?

  • Run the disk in Windows 8 Cleanup utility

    Sometimes inbetween uninstalling and reinstalling the software/drivers, it's a good idea to run the Windows Disk Cleanup utility. The disk cleanup utility to free disk space by deleting unnecessary files from your computer.

  • Flash appears in many modes?

    Very new to DSLR s, known with heavy HD video cams for pro work. I have a 60 d and I learn from her, but cannot understand why lightning appears in the shade on the many auto modes, sometimes hot flashes and sometimes just POPs. I also note that the

  • Try to install Windows 98 then switch to XP

    I have an old Emachine T1100 with 512 MB memory and I'm trying to install windows 98 on it, and then upgrade to Windows XP Home edition. I have the original disc of Windows 98, but when I try to install it continues to come with an error message indi

  • Nomination for the third Wednesday of each month

    How can I set up my monthly calendar to an event that occurs every third Wednesday of the month?  Thank you.