clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2335559 fiddles created (27412 in the last week).

create table docs(id int, dispo int, dt date, st timestamp);
 hidden batch(es)


insert into docs values (1, 10, '20170406', '2017/04/06 01:30:00'), (1, 5 , '20170407', '2017/04/07 02:30:00'), (1, 10, '20170406', '2017/04/06 01:00:00'), (1, 10, '20170406', '2017/04/06 01:15:00'), (2, 9, '20170406', '2017/04/06 01:30:00'), (2, 9, '20170407', '2017/04/07 13:45:00'), (2, 9, '20170407', '2017/04/07 09:00:00'), (2, 9, '20170407', '2017/04/07 10:45:00');
 hidden batch(es)


SELECT id ID, dt "Date", max(dispo) Disposition FROM docs GROUP BY id, dt
ID Date Disposition
1 2017-04-06 10
1 2017-04-07 5
2 2017-04-06 9
2 2017-04-07 9
 hidden batch(es)


SELECT t1.id ID, t1.dispo Disposition, t1.dt "Date", max(t1.st) Stamp FROM docs t1 JOIN (SELECT id, dt, max(dispo) as dispo FROM docs GROUP BY id, dt) t2 ON t1.id = t2.id AND t1.dispo = t2.dispo AND t1.dt = t2.dt GROUP BY t1.id, t1.dispo, t1.dt ORDER BY t1.id, t1.dt;
ID Disposition Date Stamp
1 10 2017-04-06 2017-04-06 01:30:00
1 5 2017-04-07 2017-04-07 02:30:00
2 9 2017-04-06 2017-04-06 01:30:00
2 9 2017-04-07 2017-04-07 13:45:00
 hidden batch(es)