I'm looking for help on how to get the last record for a rep by day.
Below is an example of the data, and I've included code to make the table at the bottom.
Rep Date_time acct_id action_cd result_cd
LACEL 05/01/2024 10:58:12 AM 123456 AR NT
STEMI 05/01/2024 8:50:45 AM 123456 AR NT
STEMI 05/01/2024 9:40:00 AM 123456 CT PP
I tried using over partition with rank but doesn't seem to work. Not sure if it's the right command or I'm using it incorrectly.
Results I am expecting….
Rep Date_time acct_id action_cd result_cd
LACEL 05/01/2024 10:58:12 AM 123456 AR NT
STEMI 05/01/2024 9:40:00 AM 123456 CT PP
drop table t;
create table t (rep varchar2(20),
date_time date,
acct_id number,
action_cd varchar2(20),
result_cd varchar2(20));
insert into t values ('LACEL', (to_date('2024/05/01 10:58:12','yyyy/mm/dd hh24:mi:ss')), 123456, 'AR', 'NT');
insert into t values ('STEMI', to_date('2024/05/01 8:50:45','yyyy/mm/dd hh24:mi:ss'), 123456, 'AR', 'NT');
insert into t values ('STEMI', to_date('2024/05/01 9:40:00','yyyy/mm/dd hh24:mi:ss'), 123456, 'CT', 'PP');