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

From: Daniel Roy <danielroy10junk_at_hotmail.com>
Date: 9 Jul 2003 07:03:34 -0700
Message-ID: <3722db.0307090603.39ca5d43_at_posting.google.com>


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):

SQL> create table latest (person_id number not null, date_entry varchar2(15),
time_entry varchar2(15), code number);

Table created.

SQL> insert into latest values (1, '01/01/2003', '10:00', 1);

1 row created.

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

1 row created.

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

1 row created.

SQL> select person_id, max(to_date(date_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 Received on Wed Jul 09 2003 - 16:03:34 CEST

Original text of this message