How to find the most recent record?

How to find the most recent record?

Hello

It is part of our Bill the elements table, retrieved by the following query:

SELECT movimento, dt_movimento, cd_material,
cd_tp_operacao, nf, series,
sole, pr_unitario
Of itemfat
WHERE cd_material IN ('722136', '759177', ' 810725', 818848')
AND cd_tp_operacao ("' 1102 c ' ', ' 2102 C")
ORDER BY cd_material,
dt_movimento


MOVIMENTO DT_MOVIMENTO CD_MATERIAL CD_TP_OPERACAO NF SERIES AS PR_UNITARIO
2008-03-11 2137625, 722136 2102 1084738 3 120 2 915
2588890 08/05/2008 722136-2102 1090987 3 120 2,5615
755522 09/10/2007 759177-2102 101449 1 200 0.6
701055 03/10/2007 810725-2102 1013865 1 36 10.9
1588804 20/12/2007 810725 2102 1014182 1 96 10.9
1305653 03/12/2007 818848-2102 108555 1 240 6.5
3102134 07/18/2008 818848 2102 109784 1 360 6.5


Seems that I whant to retrieve only the most recent records for each item, as:

MOVIMENTO DT_MOVIMENTO CD_MATERIAL CD_TP_OPERACAO NF SERIES AS PR_UNITARIO
2588890 08/05/2008 722136-2102 1090987 3 120 2,5615
755522 09/10/2007 759177-2102 101449 1 200 0.6
1588804 20/12/2007 810725 2102 1014182 1 96 10.9
3102134 07/18/2008 818848 2102 109784 1 360 6.5


Can someone help me with a sentece SQL to do?

Thanks in advance.

You can certainly do it:

SELECT   movimento, dt_movimento, cd_material, cd_tp_operacao, nf, serie,
         quantidade, pr_unitario
    FROM itemfat i
   WHERE cd_material IN ('722136', '759177', '810725', '818848')
     AND cd_tp_operacao IN ('1102C', '2102C')
     AND dt_movimento =
            (SELECT MAX (dt_movimento)
               FROM itemfat d
              WHERE d.cd_material = i.cd_material
                AND d.cd_material IN ('722136', '759177', '810725', '818848')
                AND d.cd_tp_operacao IN ('1102C', '2102C'))
ORDER BY cd_material, dt_movimento

: p

Tags: Database

Similar Questions

  • How to find the most recent patches autoconfig

    How to find the most recent patches in 11i autoconfig.

    Salvation;

    After you apply the hotfix 9535311, should I run autoconfig or it runs as part of the patch in bleachers apps/db.

    You will need to follow patch Readme Part.

    1.demarrez 2.1 before you apply this Patch
    2. that follow 2.2 How to apply this Patch
    3 2.3 after you apply this hotfix

    All stages of coverage in him read me part

    Respect of
    HELIOS

  • Lightroom did not find most recent backup how to find the most recent backup.

    Lightroom could not find my most recent catalog. so I told him to use the default catalog. Now I can't find the record of my last backup or my most recent photos. I use Mac 10.11.1 El captain. I used his Spot Light search with no results. I went to the mac images where I kept my backups with no result.

    Any help would be greatly appreciated.

    you want to use spotlight to search for. LRCAT not. IRCAT

  • How to find the most recently read or access files or documents.

    In XP, there is a choice of the icon when you open start botton for the most recently viewed or read files.  Once again, I would like this feature.  How?

    Currently, I click on start, then the documents, and the only choice which is "recently changed". This choice is usually useless for me.  Thank you

    Windows, which fell in the start menu because now you can pin programs to the start menu and programs have separate to show their recent files in the same kind of drop-down menu, then it has become redundant.

    In the same start menu list watch the privacy section and check the two options and apply.

    Once these programs are on the list of the start menu, make a right click and select PIN to start menu, all recent item will be on this list and can be pinned to this list.

    You can also drag and pin programs to the taskbar as well.

    Also if you want an option to see recently changed items, open your library and on the top of the left column is changed recently listed, click with the right button on this list, select send to and click on create the shortcut on the desktop, once on your desktop you can drag to your taskbar or just leave it there change the display of this page and the dates of changes will be listed.

  • How to find the most recent date prev?

    Hello

    Here is the sample table and sample data.
    CREATE TABLE t1 (code NUMBER, dt DATE, price NUMBER)
    /
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/21/2012', 'MM/DD/YYYY'), 10);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/22/2012', 'MM/DD/YYYY'), 10);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/23/2012', 'MM/DD/YYYY'), 12);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/24/2012', 'MM/DD/YYYY'), 9);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/25/2012', 'MM/DD/YYYY'), 8);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/26/2012', 'MM/DD/YYYY'), 13);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/27/2012', 'MM/DD/YYYY'), 11);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/28/2012', 'MM/DD/YYYY'), 15);
    Insert into T1 (CODE, DT, PRICE) Values (2, TO_DATE('10/29/2012', 'MM/DD/YYYY'), 15);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/30/2012', 'MM/DD/YYYY'), 13);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/31/2012', 'MM/DD/YYYY'), 13);
    COMMIT;
    I have to read the table so that I got when I read a line of CODE = 1 for DT = 30 - OCT - 2012, I have to check what was the price for the CODE = 1 in the most recent previous date (which is October 28, 2013). Then I will compare the two prices (for 30 Oct 28th) and fill out another table.

    I hope I have described the situation well.

    Could someone help me with this please?

    My actual table contains a few million lines in DEV env and a lot more in PROD.

    Thanks in advance!

    If you use the analytical function LAG you can 'Watch' data of previous lines...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select code, dt, price
      2        ,lag(price) over (partition by code order by dt) as prev_price
      3* from t1
    SQL> /
    
          CODE DT                        PRICE PREV_PRICE
    ---------- -------------------- ---------- ----------
             1 21-OCT-2012 00:00:00         10
             1 22-OCT-2012 00:00:00         10         10
             1 23-OCT-2012 00:00:00         12         10
             1 24-OCT-2012 00:00:00          9         12
             1 25-OCT-2012 00:00:00          8          9
             1 26-OCT-2012 00:00:00         13          8
             1 27-OCT-2012 00:00:00         11         13
             1 28-OCT-2012 00:00:00         15         11
             1 30-OCT-2012 00:00:00         13         15
             1 31-OCT-2012 00:00:00         13         13
             2 29-OCT-2012 00:00:00         15
    
    11 rows selected.
    
  • find the most recent record inserted by using rowid

    Yes, I suspect that it is a bad idea!

    I work with an application that has been modelled incorrectly. a historical table of the status had been modeled with a primary key on a key of the company and the entry into force instead of the date of the end of the recording of the State. There is one status as possible at the same time.

    logic has been developed to insert new records of status with the dates of null terminator and then a trigger was provided that populated end dates except the one with the MAX (ROWID). so the hope is that ROWID will always get bigger.

    now, the database has been moved in environments of promotion using data pump. in our development environments, it always seems to work. but not in promotional customers environments.

    My question is: is there a setting associated with data pump that the client has used that does not respect the ROWID as it has in our development environment?

    I'm trying to determine if there is a way to continue to use the old code without immediately re-development.

    Thanks in advance for your comments.

    so the hope is that ROWID will always get bigger.

    It is an expectation that has no guarantee of being correct. He has a very good chance that a new line will have a lower value of the ROWID.

    My question is: is there a setting associated with data pump that the client has used that does not respect the ROWID as it has in our development environment?

    There is not this setting. Data pump just inserts rows into a table. Because we cannot guarantee that the next row will have a higher ROWID, then what you are looking for there is no.

    It is time to rethink this misguided approach.

    See you soon,.
    Brian

  • I need to know how to remove the most recent version of Firefox. I JUST downloaded tonight and my computer does not have this edit bar little to work with, so I can download the reader good Adobe and my internet was screwed up ever since I downlo

    I need to know how to remove the most recent version of Firefox. I JUST downloaded tonight and my computer does not have this edit bar little to work with, so I can download the reader good Adobe and my internet was screwed up, since I downloaded the new version of Firefox. I want just the old version of this back because I can't download the Adobe stuff which is necessary to protect my computer against hackers apparently not. It would have been nice to know he had a problem with the new update of Firefox BEFORE I downloaded it. I have Vista, which is usually a problem with Adobe and Firefox. I don't seem to be able to run a lot of Adobe at all on my computer because of the Vista.

    This has happened

    Each time Firefox opened

    http://support.Mozilla.com/en-us/KB/installing+a+previous+version+of+Firefox

  • How to read only the most recent records in PL/SQL

    Oracle version: 11.2

    I have a table in ORACLE called RATES and it is EFFECTIVE_DATE, RATE_NAME, RATE_AMOUNT


    RATE
    ------------
    1 RATE_ONE 01/01/2000 0.10
    2 RATE_ONE 01/05/2005 0.15
    RATE_ONE 12/01/2010 3, 0.20
    RATE_TWO 4 10/15/2009 0.33
    5 RATE_THREE 07/09/2011 0.05
    6 RATE_THREE 31/12/2011 0.06

    A rate can be there several times, but the most recent rate is the rate of the asset. I need to query this table and want only to bring the currently active lines:
    DOCUMENTS 3, 4 and 6

    How can I do this in the most elegant way?

    I can say:

    SELECT RATE WHERE trunc (sysdate) between EFFECTIVE_DATE and trunc (sysdate);

    (it will not work. I don't know how to do this without a date column exp and then I could tell
    SELECT RATE WHERE trunc (sysdate) between EFFECTIVE_DATE and end_date

    The problem is that I can't add this column at this time, so need to find a way to do it by programming

    Published by: userLynx on February 1, 2012 08:56

    Hello

    Here's one way:

    WITH     got_r_num     AS
    (
         SELECT     rate.*          -- or list columns you want
         ,     RANK () OVER ( PARTITION BY  rate_name
                          ORDER BY          effective_date     DESC
                        )           AS r_num
         FROM    rate
    --     WHERE     ...          -- If you need any filtering, put it here
    )
    SELECT     *          -- Or list all columns except r_num
    FROM     got_r_num
    WHERE     r_num     = 1
    ;
    

    If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

    If the combination (rate_name, effective_date) is not unique, this includes all rows that have the last effective_date for this rate_name. If you want exactly one line per rate_name when there is a tie, then add the columns of tiebreaker to analytical or use ROW_NUMBER instead of RANK ORDER BY clause.

  • How to find the audio and recording mixers

    Cannot find Audio Mixers and recording in Windows 7 as I had XP

    My Medion computer purchased recently does not appear to have full audio mixer for volumes or a similar mixer to record levels as I have already in Win XP.

    Is it possible to reproduce pages of mixer teas? I would be grateful for any help on this problem.

    TIA Mike

    Cool Edit 2000 (compatibility issue)

    Hello

    The mixer similar to that of Windows XP volume has been removed in Windows 7.

    Windows 7 has its own volume mixer. Check this link for more information:

    Adjust the sound level on your computer:
    http://Windows.Microsoft.com/en-us/Windows7/adjust-the-sound-level-on-your-computer

    Cool edit 2000 is not compatible with Windows 7. Cool Edit was taken over by Adobe, a few years ago and renamed Adobe Audition. The manufacturer
    offers a paid upgrade to the software.

    Check this link for more information:
    http://www.Microsoft.com/Windows/compatibility/Windows-7/en-us/details.aspx?type=software&p=cool%20Edit%20PRO&v=Adobe&UID=2&pf=0&PI=
    6 & s = Cool % 20Edit % 202000 & os 32-bit =

    Kind regards
    Amal-Microsoft Support.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to see the most recent messages by forum

    Hi, all.

    It seems to me that I am not 'become' something about the Organization of the forums. I want to do is see the messages in every forum I'm interested, recent. What I actually see when I go to each forum is "trends" of the discussions. When I go to browse > Discussions, I can see that some of the more recent discussions are not in the category 'Trend', but go > Discussions shows a messy confusion of all forums.

    I want to help these people, but I'm afraid that their issues fall between the cracks, because they are not quite 'trends' for me to be able to see them.  How I see 'recent' discussions instead of "trend".

    Best regards;

    Amy

    Thank you all those who rushed in on this one, but I found the solution myself. (Oops, I'm being sarcastic there?)

    If you click on one of the focused themes, once you are there, there is a trail of crumbs at the top, and the last link in the chain is "discussion". If you click on that, you get to all the discussions in this forum, not only the "trendiest". I don't know why there must be this convoluted. If there is a shorter way, I would be grateful hearing on this.

  • find the most recent value based on the defined date

    Hi all

    In my example below, I want to find the last symptom and the name that was added after 24-mar-2012 (not before that). Not getting not good performance




    with xx as
    (select 101 as the ID, "A01" as name, 24 March 2012 ' than double create_date)
    Union of all the
    Select 101, "A01", March 24, 2012 "of the double
    Union of all the
    Select 102, "A02", March 24, 2012 "of the double
    Union of all the
    Select 101, "A01", March 30, 2012 "of the double
    Union of all the
    Select 102, "A02", March 30, 2012 "of the double
    Union of all the
    Select 102, "A01", April 21, 2012 "of the double
    Union of all the
    Select 101, "A01", April 22, 2012 "of the double

    ),

    XY as
    (select 101 as the ID, "Asthma" as a symptom of double
    Union of all the
    Select 101, 'cancer' of the double
    Union of all the
    Select 101, 'bpressure' from dual
    Union of all the
    Select 102, 'sbp' of the double
    Union of all the
    Select 101, 'BPD' of the double
    Union of all the
    Select 102, 'allergy' of the double
    Union of all the
    Select 103, "heart failure" of the double
    Union of all the
    Select 102, 'sneezing' from dual

    )

    Select xx, xy, xx.name, xy.symptom, xx.create_date
    where xx.id = xy.id
    Group of xx.name, xy.symptom, xx.create_date
    "After having xx.create_date > 24 March 2012"
    with xx as
    (select 101 as ID, 'A01' as name, '03/24/2012' as create_date from dual
    union all
    select 101, 'A01', '03/24/2012' from dual
    union all
    select 102 , 'A02', '03/24/2012' from dual
    union all
    select 101 , 'A01', '03/30/2012' from dual
    union all
    select 102 , 'A02', '03/30/2012' from dual
    union all
    select 102 , 'A01', '04/21/2012' from dual
    union all
    select 101 , 'A01','04/22/2012' from dual
    
    ),
    
    xy as
    (select 101 as ID, 'asthma' as symptom from dual
    union all
    select 101 , 'cancer' from dual
    union all
    select 101 , 'bpressure' from dual
    union all
    select 102, 'sbp' from dual
    union all
    select 101 , 'dbp' from dual
    union all
    select 102, 'allergy' from dual
    union all
    select 103 , 'cardiac failure' from dual
    union all
    select 102 , 'sneezing' from dual
    
    )
    
    select xx.name, xy.symptom, xx.create_date from xx, xy
    where xx.id=xy.id
    and substr(xx.create_date,4,2)>24
    group by xx.name, xy.symptom,xx.create_date;
    
  • I upgraded to Firfox 5 several times, been as up to completely remove the firfox and reinstal, I'm still getting messages that my firefox is not updated! If 5.0 is not the most up-to-date how to make the most recent version?

    WP 3.2 says Firefox is outdated, applications on facebook, I received an invitation for Google + and it said that my browser has not been supported, I had to go on safari to register.
    Yet when I click on "About Firefox" he says that I am running 5.0 and it is up to date. What is the problem with this dang browser?

    I just posted a similar problem to below. You told me the problem - thanks. My "browser wrong version" was caused by a former version being left in the "general.useragent.override" field number It would seem that this old version number would be removed after an upgrade, but the old version number is simply left there. I changed the field of:
    Mozilla/5.0 (Windows; U; Windows NT 6.0; en - us; RV:1.8.1.20) Gecko/20081217 Firefox/2.0.0.18
    TO:
    Mozilla/5.0 (Windows; U; Windows NT 6.0; en - us; RV:1.8.1.20) Gecko/20081217

  • Satellite A300: Where to find the most recent 2008 GPU driver

    Hello

    where can I get the latest drivers for a Satellite A300?
    The toshiba driver is 2008 - now, we almost 2011.
    For new software, I need the latest drivers. Toshiba stopped at 7. XX Intel itsself provides Version 15.X.

    Y at - there a Posibility to use the integrated graphics driver intel?
    Y at - there a Posibility to change the Intel driver to be installed on the laptop?

    For me, this is no ' support' to quit to force pilots with the delivery of the laptop - systems and OS change and must be updated.

    any help?

    > Is there any Posibility to use the integrated graphics driver intel?
    > Y at - there a Posibility to change the Intel driver to be installed on the laptop?

    You can try to install the driver of graphics card in the Intel page.
    If the installation using setup.exe will not work, then try to install the driver through the Device Manager.

    Here you can choose the Advanced installation procedure which allows to point to the files in the driver downloaded from Intel page and this will force windows choose exactly this driver.

    Good bye

  • Satellite Pro A200: Here you can find the most recent original Intel WIFI driver

    If you have problems with WiFi on Windows XP as I do, try to download Intel drivers not Intel support Web page.

    Download link: http://downloadcenter.intel.com/download.aspx?url=/13002/eng/11.5.0.0_x32.exe&agr=N&ProductID=2753&DwnldId=1300 2 & strOSs = 44 & OSFullName = Windows * % 20XP % 20Professiona l & lang = fra

    I hope that helps!

    See you soon

    Published by: ADMIN

    Thanks for the notification.

    But beware: the Intel Wlan mentioned package contains these driver versions:

    -Intel Wireless WiFi Link 4965AGN: 11.5.0.32
    -Intel PRO/Wireless 3945ABG Network Connection: 11.5.0.32
    -Intel PRO/Wireless 2200BG Network Connection: 9.0.4.37
    -Intel PRO/Wireless 2915ABG Network Connection: 9.0.4.37

    Best regards

  • to find the number of records retrieved in the select statement in the cursor

    Hi all
    with the cursor, I'm selecting select statement together and writing in the .txt file.
    his worksheet, but it should not open the file, if the cursor returns nothing.
    How to find the number of records returned by the select statement in the cursor.
    pls help me.

    Thank you...

    Don't understand what you're trying to say, but maybe it's...

    DECLARE
       vCounter NUMBER;
       -- Other variables...
    BEGIN
       vCounter:=0;
       FOR .. IN cursor LOOP
        IF vCounter=0 THEN
          -- Here open file...
          -- Here write one time data...
        END IF;
        -- Here write cursor data...
        vCounter:=1;
       END LOOP;
    END;
    

    -Clément

Maybe you are looking for