Question on some

How to choose the last record being updated based on 2 fields are updated in a table. I'm not concerned with other fields in the table.

For example, I have a table with columns, and the data as follows:

Salary Commission Dept_No Last_updated Emp_No

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

1 1000 10 1 10/1 / 2013

1 2000 10 10 5/1/2013

1 2000 10 20 6/1/2013

1 2000 15 20 9/1/2013

Suppose that here I fear with updates of the salary and Dept_No columns. So, for Emp_No = 1, I need the last record salary where dept_no and only is updated.

So in this case the query should return the 3rd file which is updated on 06/01/2013.  How can I write a query for this.

A way to achieve expected results; Certainly there is scope to merge analytics and reduce online views, will try to post what I get some time.

with data as
(
  select 1 empid, 1000 sal, 10 comm, 10 dept, to_date('01-01-2013', 'DD-MM-YYYY') last_update from dual union all
  select 1 empid, 2000 sal, 10 comm, 10 dept, to_date('05-01-2013', 'DD-MM-YYYY') last_update from dual union all
  select 1 empid, 2000 sal, 10 comm, 20 dept, to_date('06-01-2013', 'DD-MM-YYYY') last_update from dual union all
  select 1 empid, 2000 sal, 15 comm, 20 dept, to_date('09-01-2013', 'DD-MM-YYYY') last_update from dual
)
select empid, sal, comm, dept, last_update
  from (
        select empid, sal, comm, dept, last_update, is_modified,
               row_number() over (partition by empid order by last_update desc) rn
          from (
                select d.*,
                       case
                        when sal != lead(sal) over (partition by empid order by last_update) or
                             dept != lead(dept) over (partition by empid order by last_update desc)
                          then 1
                          else 0
                       end is_modified
                  from data d
               ) a
         where a.is_modified = 1
      )
 where rn = 1;

EMPID                  SAL                    COMM                   DEPT                   LAST_UPDATE
---------------------- ---------------------- ---------------------- ---------------------- -------------------------
1                      2000                   10                     20                     06-JAN-13

Tags: Database

Similar Questions

  • Questions about some of the keys on the keyboard

    I have Windows 7 and some of the keys on the keyboard are unknown for me. I tried to get these stars, but I got about 30 different answers and didn't know we had the right answer.

    I have a Pavilion Elite HPE-450f

    The symbols following, unknown to me at the moment are 'Fn' next to the 'Ctrl' key on botton left; a symbol of the Crescent Moon on the "F2" key a left double-arrow on the F5; a symbol unique arrow right/pause press the F6; right double stop on the F7 and an arrow symbol on the F8 key. These are the only ones that I have questions on.

    Thanks in advance for your help.

    While pressing the fn key, the arrow keys serve as common controls of media player.

    FN more Moon puts the computer to sleep.

  • question for some languages of coding

    Hello

    I build multilingual adf application.

    I use resource bundle (in the properties file) to store any translation.

    I'm running into a strange question, on 1 of the server (my only local windows-based), languages appear correctly.

    on another (dev on unix box), some languages which gives some encoding problems.

    where to check? any suggestions?

    Thank you.

    no problems encoding so I use xml (xlf or xliff) bundle as xml supports the utf-8 encoding.

  • General order questions: why some posts NOT get response

    Hi I posted 4 days ago, but responded to bobody. It's for some reason? It is very important for me to find the bug for a multiple choice application I need to build it for my students. Have I not posted? No one will find the bug? What a boring job? I do not know.

    Hello...

    I can understand that you're frustrated, but there are a lot of messages/requests

    to help every day. Everyone who knows something about trying to help.

    To sum it up for you.

    Have you any idea, how many messages that help us navigate the odds

    We get? The longest are the many positions, which

    get the right answer, but never get the tag in this way by the author of the application...

    So we go and browse only to find the answer in there... ergo (lost time).

    I just recently started here... Can't tell you the number of messages the hardcore

    guys have come in vain...

    The criteria of response to messages is: we must be online

    I would advice to lift the post... We could get it, okay?

    Man of peace

    Best regards

    Peter

  • Question is some how my toolbar superior whole, ect... is off the page now, until I crushed my pointer home upstairs and then everything comes, but right as I take a pointer off all disappears again? I need help

    I'm using firefox and the other day I was messing around with a few things at the top of the page and I guess I clicked the wrong thing because now my address bar ect... does not appear on the page more. So if I run the needle in the top of the screen, it appears like I away mouser it turns off again.

    Try to hit F11.

  • Quiz ignores questions for some users

    Hello

    I publish a series of lessons created in Captivate 3 .swf files. They are posted on a web site for users to several different offices work with. Most users will be connecting through light client machines (with limited memory / power) running Internet Explorer v 6.

    I have a reporting office when they try to do the test, it ignores the issues. (I had disabled the ability to go back, I'll be back on to try to reduce the problem that entails).

    This sounds like a performance/network problem or a problem of Flash/Captivate/IE? Any suggestions?

    Thank you
    Jenny Nilsson

    Additional research, I discovered the lesson takes 90-98% of CPU on the NEW terminals.

    I am now convinced that it is a hardware problem.

  • A question about some question of RollOver/deployment

    I m trying to make a menu that appears when I flip it and closes when I implemented it. Like the menu on this site. But it menu_mc.onRollOver = function() {}
    menu_mc.gotoAndPlay (1);
    }
    menu_mc.onRollOut = function() {}
    What do I write here? I ve tried to Stop but it stills
    }

    Thank you my...

    I'm surprised that it works for you all... the typical is to do something like that to have menu_mc contains two layers. The first layer contains the button. The second layer would be the clip that contains the menu options open.

    The clip menu to open would have two frames of each stop stock in them. The first image should contain nothing in it at all. The second image would be the options menu etc.

    Then, your code would look more like this...

    menu_mc.onRollOver = function() {}
    menu_options.gotoAndStop (2);
    }

    menu_mc.onRollOut = function() {}
    menu_options.gotoAndStop (1);
    }

  • I tried to reset my security with no lcuk question

    Hello

    When I tried to reset my security question for some purchase process and tried to use the emergency email address to reset my security information, but unfortunately I did to receive all e-mails. We need you help please.

    Thank you

    Unless it is in a spam filter, you must ask security team account Apple to reset your security questions. To contact them, click here and choose a method; If this page does not list one for your country or if you are unable to call, complete and submit this form.


    (143588)

  • Cancellation of Apple's music has grayed out some songs from iTunes game

    Background:

    • I use iTunes game.
    • All the songs in my library have been downloaded by me.
    • I tried Apple's music for a while and then cancelled.

    Question:

    • Some of the songs that I downloaded in my subscription of Apple's music are now gray out and unable to be played.
    • On the iPhone (and previously on my Mac) I wonder to renew my subscription to Apple's music when I try to read them.
    • It seems that iTunes thinks that these are songs from Apple's music, when they certainly are iTunes songs Match (most of the songs is not yet on Apple music).

    Attempted fixes:

    • I tried all kinds of re - authorize etc and nothing works.
    • I talked at length to Apple on the phone who now asked me to install OS X (which I'm hated to do that I don't see it being a problem of BONE).

    How can I return these songs? Is this a known bug?

    Okay, that was user error. The songs were incorrectly uploaded from another computer!

  • Error message: NTLDR, impossible to reinstall OS for some reason any?

    I have a Sony desktop computer, accelerated an error message and I tried everything. The error message is: NTLDR and tried almost everything. restore the original Sony VAIO CDs and he wouldn't accept, I installed my Windows XP Professional upgrade CD-ROM, but he didn't take it. The CD-ROM works fine, the system BIOS THAT were returned to their original settings, I tried Linux and he began to accept this operating system, but I still received an error...

    I am open to any suggestion that I am pretty desperate now!

    Thank you very much!

    Bruce, I was in a car accident in 1985 to where I broke only two months, my vertebrae C4 and C5. The accident left me paralyzed from the middle of the chest, but I learned shortly after; life is what you make if you can walk, talk, see or stand. 'Disabled doesn't mean impossible' http://brucewalz.com or http://windstarsc.com

    I hope that this last few issues will be the last screw of a CPU or the nail in the coffin and things are going to be buttoned. I don't want to drop an 'unknown' OS in my computer (Linux/ubuntu) and do not have my programs, discs and other devices works not properly. Who could really push me over the edge for the first time in my life and this is my question:

    Some years ago, I bought a Windows XP Professional upgrade CD and since my backup CD Sony VAIO will not be read by my CD/DVD-ROM, how to install XP on this computer? He had originally Windows XP Professional on this media, but those are the CD that cannot be read. The computer on which I had upgraded from Windows 98 to Windows XP Pro has since been dismantled and arranged so that there are no licensing issues, etc. I am sure that the CD/DVD-ROM will read a Windows CD, there has been no problem, pick up the CD of Linux, so I don't know what is not a problem with the readers.

    Once again, thank you for your time and I appreciate that very much! Bruce
    In 1985, I was in a car accident where I only broke two bones, my vertebrae C4 and C5. The accident left me paralyzed from the middle of the chest, but I learned shortly after; life is what you make if you can walk, talk, see or stand. Disabled means not impossible - unless you allow yourself to think that way... http://brucewalz.com or http://windstarsc.com

  • Everything on my screen is enlarged, and some windows/programs do not properly fit because of that. What can I do to fix this?

    I restarted, taken the battery, stop down and the problem persists. All my documents are completely expanded, I opened all the windows looks as if it is enlarged, but it is not. If I click on the maximize button, the window half fits on the screen.

    You have poorly defined display resolution. A few reasons that this can happen:

    1. a person has played one more game and the game reduced the resolution.
    2. that you have installed a video driver from Windows Update by mistake - and it is always a mistake.
    3. the video card is a failure.

    Since you did not provide a response to the first Question (see below), I can't guess what happened.

    The first Question of troubleshooting: If the problem is new, what has changed between the time things worked and the time they do not have?

    Try to set the resolution to the correct according to the instructions below. If this does not work, post is back with the answer to the first Question and some information about your computer (desktop? laptop? video card? monitor make/model, if your desktop?).

    1 start Orb > Control Panel > appearance and personalization. Click personalization, click display settings.
    2. pursuant to the resolution, move the slider to the resolution you want and then click on apply.

    MS Windows help - change the resolution of screen under Vista:
    http://windowshelp.Microsoft.com/Windows/en-us/help/0386b009-5F30-45c7-80c8-ff0395cc24091033.mspx
    MS - MVP - Elephant Boy computers - don't panic!

  • Question of running - y dllhost.exe and dllhost.exe processes * 32 (COM Surrogate) safe?

    Hello

    I have a question about some process running for all users in the Task Manager.  I noticed the following:

    Dllhost.exe
    Dllhost.exe * 32 (COM Surrogate)

    These processes are safe?  Dllhost.exe * 32 y remains fundamentally, but dllhost.exe comes and goes.  One or the other of these processes would be malware?

    Thank you
    M

    Hi clearlyembarrassed,

    Two processes are used by many programs on the computer.

    See the link below to learn more about the process in the Task Manager.

    Understand the information process in the Task Manager

    http://Windows.Microsoft.com/en-us/Windows-Vista/understanding-process-information-in-Task-Manager

    You can also check whether a third-party program is using this service trying to clean boot procedure.

    See section to learn more about how to clean boot.

    How to configure Windows XP to start in a "clean boot" State

    http://support.Microsoft.com/kb/310353

    Reset the computer to start as usual

    When you are finished troubleshooting, follow these steps to reset the computer to start as usual:

    1. Click Start , and then click run.
    2. Type msconfig , and then click OK.
      The System Configuration utility dialog box appears.
    3. Click the general tab, click Normal Startup - load all device drivers and services , and then click OK.
    4. When you are prompted, click restart to restart the computer.
  • General questions about errors in eventvwr

    Greetings.

    I have a general question about some failed modules are stored in the Windows Event Viewer.

    An error leading to the crashes some applications that I've seen several times now when supporting computer problems is something like this:
    (Windows error reporting) Fault bucket, Type 0, name of the event: PCA2, (...) P1: application.exe, (...)

    I wonder what this 'PCA2. Which is a kind of module Windows handles tasks such as allocating memory or smth. Like this? What could be the cause of these errors (physical memory problems / corrupt swap file / insufficient rights?)

    Same Question for the application falls down because of "kernelbase.dll" as in:
    (Application error) Failing application: application.exe, Version: 0.0.0.0, (...) Failed module: KERNELBASE.dll, Version: 6.1.7601.18015, (...) Path of the failing module: C:\Windows\syswow64\KERNELBASE.dll (...)

    What is the .dll file and what could possibly cause kernelbase.dll Fault?

    The application can be a bit buggy, but I wonder what could possibly cause these accidents and if there is a way to fix these problems - or what dev did wrong.

    The two errors occur mainly on x 64 systems - especially Windows 7/vista

    Kind regards

    With application errors, the application is called everything first and the module he collaborated with is named second. Normally you should try to reinstall the application if you see not to repeat the mistakes. If this does not work, you go to the forum on the application to see if other users see the same error. There may be a bug in the application.

    The observer of the Application event log contains Information reports (event ID: 1001) for errors where the details were sent to Microsoft for review. You will find that there are corresponding to the event ID: 1000 reports errors, either in the system or Application logs. These reports are also included in the center of the Action. Center type action in the area of research above the Start button and press ENTER. Click on the arrow pointing downwards to the right of Maintenance, and then click view reliability history. The errors reported are the Red orbs with a white cross. You can search for solutions to problems, but occasionally you get a significant response from Microsoft.

    I can't tell you what it means PCA2. Google did not find a significant result. The reports themselves are not unintelligible, although I have never tried to understand the meaning of a particular report. I have extracted what, in my view, is a starting point of two reports:
    Event name: PCA2 = P1: motherboard_utility_onoffchargesetup.exe P2: 4.65.0.0

    Event name: PCA2 = P1: setup.exe P2: 11.0.0.28844

    You have the app in the boredom and the version of the file. These details have been extracted a file of information system to a computer with a card mother Gigabyte. So, you see I have a starting point, if I wanted to determine the cause of a failure.

    I will say before you go dive deep into each event ID: 1001 report that many are not easy to even begin to understand. However, they can provide useful clues.

    KERNELBASE.dll is likely to be the module with which the application works. You need to focus on the application.  KERNELBASE is probably preceded by P3 or P4 in the report?

    General remarks on the event viewer:
    http://www.gerryscomputertips.co.UK/syserrors5.htm

  • LR6 won't some of my photos

    Hello

    I have a question about some missing photos in LR6. I had about 400 photos in a folder on my MacBook I transferred (by LR) to an external hard drive, a couple of days. When I open LR today, nearly half pictures were missing. They have been moved from my laptop to the external hard drive, but for some reason, LR have missed to import 200 of them. When I try to import again, I can see/choose 388 photos, but when the import starts, he says 'nothing to import. I moved 3 files at the same time, but two of the three were "intact".

    I guess the easiest thing would be to delete the LR folder and then re-import everything. I rather not do that because I made significant adjustments to some of these pictures.

    All of you who have had this problem in the past? I recently upgraded to LR - don't know if it's important.

    Kind regards

    Marten

    Looks like you have two sets of files that are identical to your hard drive. Alone is referenced in Lightroom. When you try to move the files that are referenced in Lightroom to the destination where you want, it turns out that they are already to this location. What you would do in this case is firstly move the files out of the destination where you try to move inside Lightroom files to a safe place and then move the files that are in Lightroom. It should work. When you are convinced that you have all the images you need, you can remove the extra copies. Make sure that you really understand what you're doing until you delete all the files and it might be better to simply move to a backup disk and see if Lightroom can't find all of your files in the normal places.

  • Is it possible to achieve a high level simply by means of raising the question threads?

    I just noticed a question posted by a person at a level 6-8, with more than 10 k points... and somehow the question wasn't form, standing that I expect in general that points up.  A quick glance suggests recently a large number of debates question raised and rare if no answering other questions.  I can't view the earlier story of how the points were won.  And most may indeed have been won answering the question on the other.  And somehow, I care little.  But is that what we are overemphasizing points for raising a thread that says: 'how to... '. » ?

    It's just a thought.  Maybe a confession that I sometimes pay a glance at the 'level' to answer questions; I am also aware that even the great guru can be in the "level 1"!

    Not necessarily by simply asking questions (Yes, some points are awarded, and lower levels of status do not require a lot of points to get through them), but it can also be that the person really is (it may be a surprise) marking answers as correct and useful, that rewards the further.

    So, Yes, a person can certainly win first levels quite easily by simply asking questions, as that shows they are involved, but does not necessarily mean that they are any kind of expert in the field.

    If you look at the profile of people and then move to their reputation, you can see how they earned their points; and if you see someone who appears to be games/abuse the system by simply stocks that give them points without really contributing, please feel free to raise them up to the admin who will take a look and deal with them if necessary.

Maybe you are looking for

  • Store's Down Again!

    I keep getting "Server made a mistake during the download: 503 Service unavailable." -> Why? Can anyone help?

  • Erase the macbook drive and clone in the drive of the iMac.

    Get a Macbook pro. Have an iMac. I mess up whatever it is on the book if I erase his SSD and clone in my iMac clone existing (it will fit). Never had a laptop and do not know if something unique is the reader, i.e. the trackpad software, etc..

  • Satellite L300-1BV - error windows could not start

    When I try to start the laptop it know"Unable to start windows. To address the recovery of insert problem disc etc, but I have nothing of thisbelow it I got an error message file: \windows\system32\winload.exe STATUS: 0XC000000F Info: the selected en

  • Use of the parallel port

    Hello I have a lot of experience with earlier versions of Dasylab (up to V9) and recall his ability to use the parallel port of PC as a "quick & easy" way to get digital input/output lines of the PC. If my memory serves me well, done by activating th

  • How to reduce the use of bandwidth LAN?

    I want to design a relay system using two USRP of NI USRP 2922 with sample rates even as LTE standard. But there is limitation in the use of bandwidth of 1 Gbps LAN.