Obtain registration with the maximum Date within a group

People,
Need to find the file that has the most recent date. Here's what the table looks like:
desc student_ldg;

account_number   not null   varchar2(10)
dept_code        not null   varchar2(5)
assignment_date  not null   date
We had to find the last record in the table that has the largest assignment_date.

Any help is appreciated.

Thank you

Which version of DB you are working on?

Try this

select *
  from (select * From student_ldg order by assignment_date desc)
 where rownum = 1;

Tags: Database

Similar Questions

  • Obtain registration with the date max - rank question

    I use the statement below to get rank for records with the same data with max date. But I still see rank 1. Someone help me understand this?

    SELECT T.*,
           RANK() OVER(PARTITION BY T.UNIQUEID ORDER BY T.LOADDATE DESC) RNK
      FROM DEMO_TBL T
     ORDER BY T.STARTTIME ASC
    
    create table DEMO_TBL
    (
      NUMBERID  VARCHAR2(50),
      STARTTIME DATE,
      STOPTIME  DATE,
      TOTAL     NUMBER(19,10),
      UNIQUEID  NUMBER(10),
      LOADDATE  DATE
    );
    
    
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('01-07-2013', 'dd-mm-yyyy'), to_date('01-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 705.0000000000, 15353856, to_date('06-07-2013 12:58:57', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('02-07-2013', 'dd-mm-yyyy'), to_date('02-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 698.9950000000, 15353857, to_date('06-07-2013 12:57:08', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('03-07-2013', 'dd-mm-yyyy'), to_date('03-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 701.9970000000, 15353855, to_date('07-07-2013 12:58:17', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('04-07-2013', 'dd-mm-yyyy'), to_date('04-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 91.0020000000, 15353854, to_date('08-07-2013 13:00:07', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('05-07-2013', 'dd-mm-yyyy'), to_date('05-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 90.9970000000, 15353853, to_date('09-07-2013 12:59:35', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('06-07-2013', 'dd-mm-yyyy'), to_date('06-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 91.0060000000, 15353852, to_date('10-07-2013 12:56:36', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('07-07-2013', 'dd-mm-yyyy'), to_date('07-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 91.0020000000, 15353851, to_date('11-07-2013 13:02:47', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('08-07-2013', 'dd-mm-yyyy'), to_date('08-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 91.0010000000, 15353847, to_date('14-07-2013 13:01:26', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('08-07-2013', 'dd-mm-yyyy'), to_date('08-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 91.0010000000, 15353850, to_date('12-07-2013 12:55:28', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('09-07-2013', 'dd-mm-yyyy'), to_date('09-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 1015.4440000000, 15353842, to_date('23-07-2013 12:59:34', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('09-07-2013', 'dd-mm-yyyy'), to_date('09-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 91.0000000000, 15353849, to_date('14-07-2013 12:56:59', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('10-07-2013', 'dd-mm-yyyy'), to_date('10-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 91.0040000000, 15353848, to_date('14-07-2013 12:59:13', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('10-07-2013', 'dd-mm-yyyy'), to_date('10-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 1023.9450000000, 15353844, to_date('23-07-2013 12:59:02', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('11-07-2013', 'dd-mm-yyyy'), to_date('11-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 92.0010000000, 15353846, to_date('15-07-2013 12:57:14', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('11-07-2013', 'dd-mm-yyyy'), to_date('11-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 1019.0510000000, 15353841, to_date('23-07-2013 13:01:24', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('12-07-2013', 'dd-mm-yyyy'), to_date('12-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 1042.8390000000, 15353843, to_date('23-07-2013 12:59:34', 'dd-mm-yyyy hh24:mi:ss'));
    
    
    insert into DEMO_TBL (NUMBERID, STARTTIME, STOPTIME, TOTAL, UNIQUEID, LOADDATE)
    values ('11110008524705', to_date('12-07-2013', 'dd-mm-yyyy'), to_date('12-07-2013 23:59:59', 'dd-mm-yyyy hh24:mi:ss'), 91.9940000000, 15353845, to_date('16-07-2013 12:58:28', 'dd-mm-yyyy hh24:mi:ss'));
    

    you are looking to do this,

    SELECT T.*,
    max(t.starttime) OVER(PARTITION BY NUMBERID,STARTTIME,STOPTIME,TOTAL ORDER BY T.LOADDATE DESC) mx_strt_dt,
    max(t.stoptime) OVER(PARTITION BY NUMBERID,STARTTIME,STOPTIME,TOTAL ORDER BY T.LOADDATE DESC) mx_stop_dt
    
    FROM DEMO_TBL T
    ORDER BY T.STARTTIME ASC
    
  • Difficulty in obtaining registration with the last moment!


    Hello

    I you are trying to join two tables and terms just to get the record with the highest timestamp!

    I already wrote this but do not know how should I include the RANK to get the last?

    Select i.isin, i.id, i.mkt, i.tm, o.obst, row_number () on)

    rank of partition by order of i.tm desc i.id)

    of instrument_info i, orderbookstate o

    where i.id = o.id

    and i.mkt = o.mkt

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

    CREATE TABLE ORDERBOOKSTATE

    ( ID             VARCHAR2(33 BYTE) NOT NULL,

    MKT           VARCHAR2(11 BYTE) NOT NULL, 

    OBST         NUMBER(2),

    TIME_INSERTED VARCHAR2()20 BYTE)

    );

    CREATE TABLE INSTRUMENT_INFO

    (

    ISIN VARCHAR2 (13 BYTE) NOT NULL,

    ID VARCHAR2 (33 BYTE),

    VARCHAR2 (20 BYTE) TM,

    MKT VARCHAR2 (11 BYTE) NOT NULL,

    NUMBER (10),.

    CTL VARCHAR2 (4 BYTE)

    );

    insert into INSTRUMENT_INFO (ISIN, ID, TM, MKT, ITY, CTL)

    values ('SE0001535568', 'LLSW-B','2013-03-11 06:55:11 ', 'SSEFN', 0, 'SEK')

    insert into INSTRUMENT_INFO (ISIN, ID, TM, MKT, ITY, CTL)

    values ('SE0005126125', 'LLSW-B','2013-11-08 06:57:20 ', 'SSEFN', 0, 'SEK')

    insert into ORDERBOOKSTATE (id, mkt, obst, time_inserted)

    values ('LLSW-B', 'SSEFN', 4,'2013 - 11 - 08 12:37:27 ');

    When I add the rank = 1, it returns me an error!

    Do you know how should I join them to get just the last?

    Need any more made Hotel me know!

    Thanks in advance!

    Select * from

    (

    Select i.isin, i.id, i.mkt, i.tm, o.obst, row_number () on)

    rank of partition by order of i.tm desc i.id)

    of instrument_info i, orderbookstate o

    where i.id = o.id

    and i.mkt = o.mkt

    )

    where rank = 1

  • Download all packages or just the sound with the latest dates?

    Hi, maybe it's a stupid question, but when you go to the drivers and it shows are all pilots who are selected to download to your laptop you wanted to install only those with the latest dates or each package that is there?

    Hello:

    You must install the driver with the most recent date if you are sure this is a driver that you are interested in.

  • How to create two different smart albums with photos with the same date?

    I created a smart album by using 'Date is' and ' keyword is EAA.»  (The photos have a keyword like "EAA" or "Flower".  Photos of keyword EAA & flower have the same date.)  When I use "Corresponding to all" are has no pictures in the album.  When I use "Match any" all the photos are in the album - EAA & flower.  I would like an album with only pictures of CEA for that date and another album with photos of flower with the same date.

    I get the same answer.  I can get the date and to a key word to work with 'all' selected, but not date and keywords.  So you will need two smart albums: one with date and ECA ('all' selected) and the other with date and flowers ('all' selected).

    Use the file menu option ➙ new Smart Album.

    Report the problem to Apple via https://www.apple.com/feedback/photos.html.

  • Is there a problem with the maximum size of the RAM for Satellite 320CDT?

    I have a 320CDT Satellite with the latest BIOS (v8.00) and Windows 98 Second edition installed. There are 32MB memory base and a 32 MB module in the single expansion slot. If I change it to a plug-in 64 MB I see that 64 MB of total memory reported, not 96 as expected; the specification for the machine indicates that the admissible maximum memory is 160 MB (32 MB base + 128MB expansion). Does anyone know if there is a problem with the maximum memory size for this model and if there is a solution or workaround? I need to know quickly, in order to decide if I should return the memory module to the vendor! Thanks a lot for any help, Peter

    Satellite 320CDT supports an internal memory of 32 MB and a single slot can be used!
    You can improve it to max 96 MB (32 + 64 MB)
    I found a few old memory modules. You can use the modules SODIMM 144 pin EDO PA2043U 32 MB or 64 MB PA2044U

    Greetings

  • problem with the backup data in text file

    Hello

    The problem I am facing wihile, saving the data in the text file is that everytime when I'm slecting the path of the façade, data that are recorded are added with the previous data, not only in the new text, the new data set is saved but also, is there any previuos run for the program , the corresponding data is also present in this text file.

    However, when I change the same ''(file path) to 'constant' in the control block diagram, and then add the path of the file, it doesn't have this problem. Basically, changing the "file path" constant in the diagram of control block (so that it is displayed in the front panel) is at the origin of the problem.

    Help, please!

    Thank you

    Your shift on the loop Register For is not initialized. It will keep the value of the string since the last time that he performed. That initialize and it should solve your problem.

  • DLL for LabWindows/CVI 8.0 with the bool data type

    Hello

    I want to use a new SWIR camera in LabWindows/CVI 8.0 (Windows XP 32bits).

    The company delivered with the camera produced a 32-bit dll by using Microsoft Visual C++ 2010. The .dll and .lib and .h files include a working SDK/API (some functions with the bool data type)

    Compilation-online syntax error, variable Boolean is not a data type in LabWindows/CVI 8.0

    Generate the import of DLL-online syntax error library

    I tried to convert bool char (typedef unsigned char bool => no more syntax error but the functions does not work.)

    What can I do?

    Martin

    Hello again, Naumann!

    Microsoft Visual C++ 2010 represents Boolean using 1 byte, as stated by MSDN: https://msdn.microsoft.com/en-us/library/tf4dy80a(v=vs.100).aspx

    I guess that you import C++ functions using the syntax for extern "C". Otherwise, because of the C++ name mangling wouldn't you able to bind C++ library against your code CVI.

    You can also specify how you import C++ functions?

    In addition, because you have not described the problem as a corruption of heads or runtime error, I guess the C++ library function is called correctly the CVI. That said, I tend to believe that the problem is not really in the mechanism of interaction of C/C++, but in the C++ library. If you would start calling a dummy C++ function returning an integer from a simple CVI application that should work, because redefine bool in CVI 1 byte must ensure that settings are correctly transferred onto the stack.

    If you need to create a wrapper function of C++ that is not using bool and calls the C++ function, I expect to return the same result.

    Maybe you are missing a few prior initialization steps required? The provider of the camera also comes all example code?

    Best regards!

    -Johannes

  • As an operator with the long data type

    Oracle 10g.

    Hi gurus

    I want to apply as an operator on the long data type, but I get the error message, can you please help me why is that I use as an operator with the long data type. I did some research and but unable to find a solution, see query for more details below...

    Query

    SELECT trigger_body FROM user_triggers

    WHERE trigger_body LIKE '% UPDA % CASE % ';

    Error

    ORA-00932: inconsistent data types: expected NUMBER got LONG

    00932 00000 - ' incompatible data types: wait %s %s got. "

    * Cause:

    * Action:

    Error on line: column 2: 7

    Concerning

    Muzz

    Adrian Billington wrote to the top of your options.

    working with long columns

  • Insert/update the column with the clob data type

    Hi all

    ORCL Version: 11g.

    I have a table with the clob data type.

    Test12

    (col1 clob);

    I'm trying to insert/update to update the column with more than 4000 characters.

    But due to the limitation of tank 4000, I could not Insert/Update.

    Need your help in resolving this issue.

    THX

    Rod.

    The limit of 4000 characters is incorrect.  That pertains only to the varchar2 data type.  A clob can hold more than 4 G.

    Here is an example that shows how to insert it, I found...

    Otherwise, here is a way 'dirty' to do.

    insert into your_table (COLA, COLB)

    values

    (PRIMARY_KEY, PART 1 OF DATA)

    ;

    Update your_table

    Define COLB = COLB | PART 2 OF BIG DATA

    where COLA = PRIMARY_KEY;

    Update your_table

    Define COLB = COLB | PART 3 OF BIG DATA

    where COLA = PRIMARY_KEY;

    .. and so on...

    I don't know that I personally recommend the second style...  But he could do the job.

  • Find the next available date which is not necessarily the maximum Date

    Morning people!

    I'm trying to find the next date of appointment (including any day after today) for a patient who may not be the maximum date for this person. I am doing this in Oracle Forms. My query works in SQL * more, but does not work in forms.
    FUNCTION get_next_sched_date(P_PATIENT_ID in varchar2) RETURN DATE IS
      v_next_scheduled_date   patient_visit.target_date%TYPE;
    
    BEGIN
      select next_target_date into v_next_scheduled_date
      from   ( select v.*, max(target_date) over (partition by patient_id) max_target_date,
                           lead(target_date) over (partition by patient_id order by target_date) next_target_date
               from   patient_visit v)
      where  patient_id = P_PATIENT_ID
      and    next_target_date >= SYSDATE
      and    max_target_date > next_target_date;
    
      return( v_next_scheduled_date );
    
    EXCEPTION
       when NO_DATA_FOUND then
         return(NULL);
    When I compile in Oracle Forms, it gives me an Error.Encountered symbol "(" quand attend une deles de valeurs suivantes:, de.) "

    I also noticed that Oracle Forms is not taste keywords such as LAG and LEAD. I'm working on Oracle Forms 9i.

    No idea what I'm doing wrong here? Thanks for listening to my harping on Monday. :-)
    Forms [32 Bit] Version 9.0.4.0.19 (Production)
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    Published by: Roxyrollers on August 27, 2012 08:43

    Published by: Roxyrollers on August 27, 2012 08:46

    Hello

    The forms PL/SQL engine is never at the same level as the database one. It seams that you are using an older version of forms.

    François

  • quickly create with filter-date and initialize it with the current date

    Oracle BI 11 g

    Hello!

    I need to create guest of dashboard with filter-date and initialize it with the current date. How can I do?

    I tried to create the repository initialization block and add a variable. But I don't know what should I write to DataSource? I tried using the Current_Date, Now(), sysdate functions (for example, SELECT Now() FROM tbl_Calendar) but without results - when I pressed the button "Test"... "I have errors - something like 'Now() is unknown function' or 'incorrect syntax near keyword Current_Date.

    After that, I made to use presentation Variable in the command prompt, but also without success (())

    Please, help me.

    Use "Server Variable.

  • Need to create a new line in the table with the same data as the primary key, but new PK

    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    user9970447 wrote:
    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    something like

    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')
    
  • Problem with the CLOB data type.

    Greetings,

    I am facing a problem with the CLOB data type. I know that the CLOB data type is 4 GB (I use Oracle 9i). But in the Pl Sql procedure, I can only store 34305 size for a CLOB variable character data.

    This is the test script that I am trying to run.

    DECLARE
    -Local variables here*.
    I have INTEGER;
    C_1 CLOB.
    BEGIN
    FOR Rec IN (SELECT
    *
    ACCORDING TO THE TABLE)
    LOOP
    C_1: = c_1 | Rec.Clo_1;
    END LOOP;
    EXCEPTION
    WHILE OTHERS THEN
    Dbms_Output.put_line (SQLERRM);
    END;


    Here variable C_1 range value 34305 good character regardless of type CLOB. Now the above script fails if query my buckle - huge number of return values. It is throwing the exception "error during transfer of files ORA-06502: PL/SQL: digital error or value."

    He would be grateful if someone can help me on this.

    Thank you.

    You are probably better off using DBMS_LOB.append, instead of the concatenation of varchar2 (|).

    And... take off your when-other Manager exceptions, please...

  • Question about report with the format "Date."

    Hello friends! I want to make a line chart with a measure on the columns and type 'date' Format (MM/dd) data on lines and my report is invited with the type 'date '. In my dashboard page, I have a prompt with the Date and the operator is "BETWEEN".

    For example if I choose in my line of the first date: 01/01/2009 and the second date: 01/10/2009 in my chart, I see the results between these dates. But my question is... I see the same date last year? I mean if I choose the 01/01/2009 - 10/01/2009 I see this line and another line with 01/01/2008-01/10/2008. Is this possible?

    Because in my guest I can't type a variable presentation because date type is not taken care of...


    Thank you very much!!

    Let's say you have fresh measure
    then in your SPR you create logical column with the AGO formula (costs, TimeDim.YearLevel, 1)-Let's call him ' py 'measure.
    This will be your column YAGO...

    now in your report - you drop date, measure and measure columns py... it should work as long as you have the right size of set up time

Maybe you are looking for

  • Droid Bionic and Jelly Bean

    Hey everybody, I know im just so excited that you all with the soaking passes quickly for Ice Cream Sandwich! but I have a little problem... Ice Cream Sandwich has been out for almost a year now, so basically we update an ancient BONE with another ob

  • Laptop HP Pavilion 15 for Window 7 64 bit drivers

    Hey Im trying to find and install the drivers for my new computer to Win7, but I'm a little to accomplish I have a HP Pavilion 15-n038so Ref: F1E04EA #UUW, if someone could give me some tips where I can find em. So far, I have the drivers for the Eth

  • Part numbers

    I know that this is perhaps not the best place to ask this question. Does anyone know how to get a good number of 'catalogue' of old lifestyle site Web of National? Intuitively: "products and Services > software" >?  I want a PN for developers Suite!

  • What is ox error 80070057

    I can't put a video I did in Movie maker from my pictures or play a movie I did in Movie maker. He tells me that there is an ox80070057 error. How can I fix this. It didn't the last time I made a movie.

  • Helmet Xperia Z2 undetected since update 402

    Since the last update (17.1.1.A.0.402) helmet is not detectend when it is connected to the phone. It applies to the standard headphone and noise cancelling. Headphones work fine (tested on another audio player). I need a solution as soon as POSSIBLE