clear markdown compare help best fiddles feedback dbanow.uk
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. 2591614 fiddles created (45715 in the last week).

CREATE TABLE sample_data ( concurrent_users int , concurrent_timestamp timestamp , concurrent_date date ); INSERT INTO sample_data VALUES (3, '2020-06-24 07:20:00', '2020-06-24'), (7, '2020-06-24 08:20:00', '2020-06-24'), (8, '2020-07-05 06:20:00', '2020-07-05'), (2, '2020-07-05 03:20:00', '2020-07-05');
4 rows affected
 hidden batch(es)


SELECT DISTINCT ON (concurrent_date) * FROM sample_data ORDER BY concurrent_date, concurrent_users DESC;
concurrent_users concurrent_timestamp concurrent_date
7 2020-06-24 08:20:00 2020-06-24
8 2020-07-05 06:20:00 2020-07-05
 hidden batch(es)


-- we don't need the redundant column concurrent_date SELECT DISTINCT ON (concurrent_timestamp::date) * FROM sample_data ORDER BY concurrent_timestamp::date, concurrent_users DESC;
concurrent_users concurrent_timestamp concurrent_date
7 2020-06-24 08:20:00 2020-06-24
8 2020-07-05 06:20:00 2020-07-05
 hidden batch(es)