Hello
Using "distinct on" without specifying an explicit "order by" is unpredictable in itself. I'll quote from the manual:
> Note that the “first row” of each set is unpredictable unless ORDER BY is used to ensure that the desired row appears first.
Can you reproduce the unexpected behavior with explicit order by clause?
regards, Sergei