CREATE table rob.d20200330
(
prem char(3) not null,
batch char(4) not null,
RDATE dec(8, 0) not null,
rtime dec(6, 0) not null
);

insert into rob.d20200330
values('100', 'MR07', 20181212, 100000)
;
insert into rob.d20200330
values('100', 'MR07', 20181212, 110000)
;
insert into rob.d20200330
values('100', 'MR07', 20181213, 100000)
;
insert into rob.d20200330
values('101', 'MR08', 20181212, 100000)
;
With t1 as (
select prem, batch, rdate, max(rtime) as rtime
from rob.d20200330
group by prem, batch, rdate)
select d.*
from t1 left join rob.d20200330 d
on t1.prem=d.prem and t1.batch=d.batch and t1.rdate=d.rdate and t1.rtime=d.rtime
;

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.