Re: How to retrieve latest record when date and time are separate ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Roy

    Re: How to retrieve latest record when date and time are separate ?

    Here's what I came up with (sorry if it doesn't exactly match your
    example, but I could only work with the info you provided):

    SQLcreate table latest (person_id number not null, date_entry
    varchar2(15),
    time_entry varchar2(15), code number);

    Table created.

    SQLinsert into latest values (1, '01/01/2003', '10:00', 1);

    1 row created.

    SQLinsert into latest values (1, '01/07/2003', '10:00', 2);

    1 row created.

    SQLinsert into latest values (2, '01/01/2000', '10:00', 3);

    1 row created.

    SQLselect person_id, max(to_date(dat e_entry || ' ' || time_entry,
    'DD/MM/YYYY HH24:MI'))
    2 from latest group by person_id;

    PERSON_ID MAX(TO_DA
    ---------- ---------
    1 01-JUL-03
    2 01-JAN-00

    HTH

    Daniel
Working...