When I run
SELECT DISTINCT ON (ts) *
FROM tbl
WHERE clause=100
AND ts <= '2018-04-02 15:11:18.819000'
AND ts > '2018-04-02 15:06:18.819000'
ORDER BY ts, version ASC;
I expect a single row corresponding to the largest ts
that meets the condition, with ties being broken by taking the lowest version
.
The query returns
ts version
'2018-04-02 15:07:04.828' ... 1
'2018-04-02 15:07:05.706' ... 1
I don't understand why two non-distinct ts
are being returned. Is there a similar query that will return the desired result?