Retrieve the most recent history records from a history table

I have a table which stores movement of applications or files. There could be any number of history records for any file in this table. I can know who has a given file right now by using max(date) and the unique id field using the query below:
SELECT IS_WITH FROM APPLICATION_MOVEMENT WHERE DATE_SENT = (SELECT MAX(DATE_SENT) FROM APPLICATION_MOVEMENT WHERE APPLICATION_ID = 461)
However, my problem is, I want to return a list of all the files and who has them currently, how can I get this....i cannot enter the APPLICATION_ID anymore....
Table Name: APPLICATION_MOVEMENT
Field 1: IS_WITH
Field 2: DATE_SENT
Field 3: APPLICATION_ID

This?
WITH application_movement AS
SELECT 1 application_id, 'Greg' is_with, to_date('01-jan-07') date_sent FROM dual
UNION ALL
SELECT 1 application_id, 'Steve' is_with, to_date('01-feb-07') date_sent FROM dual
UNION ALL
SELECT 2 application_id, 'Bill' is_with, to_date('01-feb-07') date_sent FROM dual
UNION ALL
SELECT 2 application_id, 'Fred' is_with, to_date('01-mar-07') date_sent FROM dual
UNION ALL
SELECT 2 application_id, 'Jim' is_with, to_date('01-apr-07') date_sent FROM dual
SELECT DISTINCT application_id,
       FIRST_VALUE(is_with) OVER (PARTITION BY application_id ORDER BY date_sent DESC),
       max(date_sent) OVER (PARTITION BY application_id)
FROM   application_movement;
APPLICATION_ID FIRST MAX(DATE_
             2 Jim   01-APR-07
             1 Steve 01-FEB-07Greg

Similar Messages

  • Need to retrieve the most recent record per deposit number

    Can someone please show me a way to solve my problem or at least point me in the right direction.
    I have a simple bibliography table called mdd_biblio that has 3 fields:
    bib_mdd_no this is a deposit number
    bib_upd_by person who updated the record
    bib_upd_date date the record was updated (timestamp)
    A deposit might have more than one bibliographic entry with either the same date or a newer date and, the deposit might have one or more person updating the bibliography
    The table has 4974 records but only 1867 are unique deposit numbers
    All I want to do is select a single record that indicates when the deposit was last edited and and who did the editing (as indicated by the *). I don't care which record it is as long as it is the most recent date.
    The following query retrieves 1944 records (67 duplicates) and has eliminated 3000 duplicates but hasn't eliminated them all. Why?
    select unique(bib_mdd_no), bib_upd_by, bib_upd_date from mdd_biblio
    order by bib_mdd_no
    M64C/16-001 MDD 13-SEP-07 *
    M64C/16-001 MDD 13-SEP-07
    M64C/16-002 DPROUXE 30-NOV-07 *
    M64C/16-002 MDD 13-SEP-07
    M64C/16-002 MDD 13-SEP-07
    M64C/16-003 DPROUXE 29-NOV-07 *
    M64C/16-003 MDD 13-SEP-07
    M64C/16-003 MDD 13-SEP-07
    M64C/16-004 MDD 13-SEP-07 *
    M64C/16-004 MDD 13-SEP-07
    M64C/16-005 MDD 13-SEP-07 *
    M64C/16-005 MDD 13-SEP-07
    M64C/16-006 DPROUXE 03-DEC-07 *
    M64C/16-006 MDD 13-SEP-07
    M64C/16-007 MDD 02-OCT-07 *
    M64C/16-008 MDD 02-OCT-07 *
    M64C/16-009 MDD 02-OCT-07 *
    M64C/16-010 MDD 02-OCT-07 *
    I don't understand why of these duplicates still show up here since 3000 have been eliminated..
    To Reiterate: What I really need is a simple query to retrieve the most recently edited record for each deposit number regardless of the updater's name. I need this in order to build a summary table from this and 15 other tables.
    Thanks for any help you can give
    Glenn

    Usually it is done somehow like this
    select bib_mdd_no,
           bib_upd_by,
           bib_upd_date
      from (select bib_mdd_no,
                   bib_upd_by,
                   bib_upd_date,
                   row_number() over (partition by bib_mdd_no order by bib_upd_date desc) r
              from mdd_biblio
    where r = 1
    order by bib_mdd_noRegards
    Etbin

  • HT201269 i backed up my iphone to iTunes and then when i restored the back up info was not from the most recent backup, but from May!!! what can I do to get yesterdays data?1

    i backed up my iphone to itunes and tried restoring the info on to a new iphone and for some reason it used an old back up from last may.  I know that the recent back up worked as I used it to set up another phone a week ago (a phone whihc also had problems and hence I needed to use that same back up again on my second new phone.  Is there anyway I can get the most recent back up information back?

    1. Create a backup of your iPad to iTunes on your computer or to iCloud
    2. Transfer any and all photos & videos on your iPad to your computer.
    3. Erase the iPad and restore the iPhone's iCloud backup to the device.
    4. Transfer any and all photos & videos on your iPad to your computer.
    5. Restore the iPad backup you reated in step #1 back to the iPad.

  • I can't scroll in Firefox using the touchpad on my Window 7 (64-bit) laptop. I have uninstalled and reinstalled the most recent touchpad driver from the manufacturers website but this does not resolver the issue. Any suggestions?

    Driver- Synaptics 15.3.22.0
    Samsumg npqx411-w01us laptop

    Thx for suggestion... but it is two fingers on this one, and please note that scrolling works fine in Chrome and IE... the issue seem to be related to Firefox browser in some way.
    Hope you guys can help me out :S

  • Most recent date (UDATE) from CDHDR table based on CDPOS

    Hi,
    I am working on one object where i stuck with one issue. The requirement is I have to retrieve the most recent date from CDHDR table based on CHANGENR in CDPOS table. Where i am doing FOR ALL ENTRIES on CDPOS table to get the MAX( date )and i got the error, that aggregate functions are not allowed except COUNT( * ) with for all entries.
    Any thread which can solve this issue would help aswel.
    Please guide me how to achieve this. <removed>
    Edited by: Thomas Zloch on Mar 13, 2010 9:10 PM

    Hi Li,
    Thats was really helpful information , infact my requirement is same as what you said. I even checked in the table entries there is only one changenumber.
    You said we can take the first record, i even did the same. But for TABNAME I have to pass 3 table name 'LFA1', 'LFB1' and 'LFM1'. For FNAME 'LOEVM', 'SPERR'. I have written the code as below.
      SELECT objectclas
                   objectid
                   changenr
                   FROM cdpos
                   INTO TABLE i_cdpos_a1
                   FOR ALL ENTRIES IN i_lfabm1
                   WHERE objectclas = c_kred               "KRED
                   AND objectid EQ i_lfabm1-objectid       "Lifnr
                   AND ( tabname EQ c_lfa1 OR tabname EQ c_lfb1 OR tabname EQ c_lfm1 )          "LFA1, LFB1 and LFM1
                   AND ( fname EQ c_loevm OR fname OR fname EQ c_sperr )    "LOEVM, SPERR
                   AND value_new EQ c_x.
            IF sy-subrc EQ c_0.
              IF i_cdpos_a1[] IS NOT INITIAL.
    Select UDATE from CDHDR based on CHANGENR in CDPOS.
                SELECT objectclas
                       objectid
                       changenr
                       udate
                       FROM cdhdr
                       INTO TABLE i_cdhdr_a1
                       FOR ALL ENTRIES IN i_cdpos_a1
                       WHERE objectclas = c_kred             "KRED
                       AND  objectid EQ i_lfabm1-objectid               "Lifnr
                       AND changenr EQ i_cdpos_a1-changenr.   "(this is coming from CDPOS above selection)
    Here i got UDATE which have all the dates from 3 tables. I have to display in the output the field value (X) of LOEVM and UDATE for LFA1, SPERR value and UDATE for LFA1.Same way for other two tables, I have to display the UDATE and its field value (X). Where UDATE should be most recent date respectively.
    How can I populate the Recent date (UDATE) from one interal table for indvidual field values and table names.

  • How to get the Most RECENTLY installed JRE path and version ?

    Hello Experts,
    I am working on Installshield, and for some purpose, I need to get the MOST RECENTLY installed JRE version and Path. Now I have two choices :
    1. Go into the directory " C:\Program Files\Java\" and get the most recently changed directory, ( that will be the installation directory of the most recently installed JRE ). And then search in the registry under : HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java Runtime Environment/ and look for the version which is having
    the value of the key INSTALLDIR as the above found Installation Directory.
    But in this approach, I'll never find the Installation dir or version, if the JRE is installed somewhere else than the default location.
    2. Now this is the reverse. I first search in the registry, and get the Installation Directories of all the versions installed in the system, and then look at the file attributes ( may be by using some batch file ) and see which one is most recently installed.
    My question is, is there any other way, by which I can get the most recently installed JRE's installation Path and version? Or can we trace it during the installation itself ? I mean when we install the JRE, it creates some log files in %TEMP% directory. Is it possible to trace the version and installation directory of the most recently installed JRE from the log file ?
    Thanks
    Gagan

    Rendering times are pretty much based on processor speed if I have that right. Not much you can do about that other than buy a new computer. Your day to day work in the finder and accessing of files would be faster with your boot drive internal. One thing you can do is ensure your FCP System Settings are on the fastest disk you have. If you put a pair of drives internal and made a RAID volume for them you would improve your write speed when capturing and for any other read/write operations. You would have to be sure you kept that backed up properly because you double the odds of a failure when two drives spread the data between them. There are many RAID options.
    You could also bump up the RAM but you'd have to look at your processes to see if you are being limited by RAM. I'm guessing not but it's not impossible. If you are accessing scratch disks due to RAM limitations that would be one thing you could do.
    I would never bother connecting an external via USB if there was an esata or firewire option. I use an esata card internally to give me access to estata storage. I also keep an external FW800 drive for a mirror backup of my boot drive. All my data and booting is internal with all my backups external. Each internal has an external and I have additional externals that I keep off site to protect against fire and theft.

  • I just opened my mail on icloud and all messages disappeared from the last year! I have one email left in my inbox which is the most recent. I moved to icloud 2 weeks ago and it has been working fine until now. How can I retrieve old messages? Thank you.

    i just opened my mail on icloud and all messages disappeared from the last year! I have one email left in my inbox which is the most recent. I moved to icloud 2 weeks ago and it has been working fine until now. How can I retrieve old messages? Thank you.

    I guess you could try but I don't believe Apple can help with activation lock issues.  They may, however, be able to determine if the Apple ID belongs to one of you and reset the password for you if you can prove your identity.
    You might want to try calling Apple by going to https://expresslane.apple.com; click 'More Products and Services, then 'Apple ID'.  In the next page select 'Other Apple ID Topics' then 'Lost or forgotten Apple ID password'.  Perhaps they can help determine if it's your ID and reset the password for you (and they probably have more expertise in doing this than the Apple store).

  • Help, I have just restored my iphone from last back up to retrieve vital messages that somehow disappeared.  Now I have lost the most recent messages, calendar details and photos.  How do I get them back?

    Help, I have just restored my iphone from last back up to retrieve vital messages that somehow disappeared.  Now I have lost the most recent messages, calendar details and photos.  How do I get them back?
    I have an iPhone 5S

    You restore from the backup that contained them.
    Restoring from a backup is all or nothing. It completely overwrites the data in the phone when you restore. You can not combine the contents of a backup with what's currently on your phone.

  • How to restore from a session that is not the most recent

    I used the Forget button and it closed out of my windows and opened a clean window. I've started up and closed out of Firefox several times since then so using any type of 'Restore Previous Session' option won't work because the tabs I want aren't the most recent. The ones that I want were what I had before I clicked the forget button. I want to know if there's a way to restore from past sessions.

    Sorry, but not. Because the function of this button is exactly like if you made clean record.
    Grettings!

  • Is it possible to restore an iPhone 6 from a backup that isn't the most recent?

    Hi there
    I accidentally deleted a thread of text messages which contained important info that i need to retrieve.
    I then connected the phone to my iMac so i could try and restore it from a back up to get the messages back, but it automatically backed the phone up (after i had deleted the messages).
    I then went into iTunes and chose to restore the phone from a backup (thinking it would give me the option to chose a backup prior to deleting the text messages), but sadly not. It automatically started backing up from the most recent backup which is obviously not going to get my messages back.
    Is there a way to chose an older back up so i can retrieve the messages?
    Thanks in advance.
    Will

    Go to iTunes>Preferences>Devices and see what the date of the most recent backup.
    If that b/u has the data that you want to retrieve then restore using that b/u. If you b/u does not have the info then you are out of luck unless the carrier maintains a b/u of messages sent to your phone. I suspect that the carrier would only have the messages sent over their system and not from WiFi.
    MJ

  • Select the Most Recent Record

    I have a 2-page report that is grouped by employee, where the first page is a standard letter except for address, and the second page is a reproduction of a scanned form that the employee had returned.  The employee may have returned several versions of the form over time, updating it each time.
    I would like to have the report only pull in the most recent scanned image, ignoring all prior images.  I'm struggling with the correct record selection criteria. 
    Any help would be appreciated.
    Thank you.

    Hi,
    If you have any date field in the data base that updates the time whenever the image is updated then use that date field in the report-->record sort expert and use ascending order. Now place the image field from the data base in the group footer of Employee which shows the latest image. If you want the old one then goto record sort expert and change the order for date field to descending.
    Regards,
    Raghavendra

  • Removing the "sort by: most recent" default option from my purchased items.

    Is there a way to remove the "sort by: most recent" default option from my purchased items? It annoys me to see items that are not ordered alphabetically or by release date so I do not want there to be a record of this.

    See:
    * https://support.mozilla.com/en-US/kb/Resetting%20preferences

  • Remove the duplicate rows but keep the most recent and oldest records

    I have a Product table, some products have duplicate rows(same productID). I want to keep the most recent and the oldest records based on ETL load date (or min and max productKey), delete others. How to do this in a simple way?
    ProductKey | ProductID |ETL_Load_Date
    1001 | 501 | 2014-01-01
    1002 | 501 | 2014-01-02
    1003 | 501 | 2014-01-03
    1011 | 502 | 2014-01-01
    1012 | 502 | 2014-01-02
    1013 | 502 | 2014-01-03

    declare @table table (ProductKey int, ProductID int, ETL_Load_Date date)
    insert @table (ProductKey, ProductID, ETL_Load_Date)
    values
    ( 1001 , 501 , '2014-01-01' ), ( 1002 , 501 , '2014-01-02' ),
    ( 1003 , 501 , '2014-01-03' ), ( 1011 , 502 , '2014-01-01' ),
    ( 1012 , 502 , '2014-01-02' ), ( 1013 , 502 , '2014-01-03' )
    SELECT *
    FROM @table t
    INNER JOIN (
    SELECT MIN(etl_load_date) min_load_date, MAX(etl_load_date) max_load_date, ProductID
    FROM @table
    GROUP BY ProductID
    ) m
    ON t.ProductID = m.ProductID
    AND t.ETL_Load_Date IN (min_load_date,max_load_date)
    This will show both the min and max load dates, for each ProductID
    Thanks to Saeid for posting some test objects.

  • HT3275 Can't restore from the most recent TM backup

    I mistakenly permanently deleted a file from my Mac OSX disk. I then tried to retrieve it from the most recent backup on Time Machine. However, while it showed the backup from a few hours ago on the time scale on the right of the screen, I could not select it. When I click the restore button it takes me to a backup of a week ago.

    15A How do I use the (not so intuitive) Time Machine display?
    15.  How do I view or restore selected items?
    From Pondini’s excellent Information Here...
    http://pondini.org/TM/FAQ.html

  • I just downloaded to the most recent version of Firefox, and lost my Delicious bookmarks. How can I retrieve them?

    I just downloaded the most recent version of Firefox, and my Delicious bookmarks have disappeared. How can I retrieve them?

    First, are you positive it is really not there?  Have you looked in your iTunes folder in your Music folder, and in the media folders there? Do you see your media files?
    If your media are gone it is a lot easier to restore from a proper computer backup.  Your i-device was not designed for unique storage of your media. It is not a backup device and media transfer was planned with you maintaining a master copy of your media on a computer which is itself properly backed up against loss. Syncing is one way, computer to device, updating the device content to the content on the computer, not updating or restoring content on a computer. The exception is iTunes Store purchases which can be transferred to a computer.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer - http://support.apple.com/kb/HT1848 - only purchases from iTunes Store
    For transferring other items from an i-device to a computer you will have to use third party commercial software.  See this document by turingtest2: Recovering your iTunes library from your iPod or iOS device - https://discussions.apple.com/docs/DOC-3991

Maybe you are looking for