Hello,

(I googled and read docs before sending this e-mail).

Is it necessary to use order by twice (inside and outside) to get the proper order if I have an ordered subqery in a join?

select * from (select distinct on (b_id) * from a order by b_id, id) sub left join b on b.id = sub.b_id;

or

select * from (select distinct on (b_id) * from a order by b_id, id) sub left join b on b.id = sub.b_id order by b_id;


It seems to me that it's enough to use 'order by' only inside wheter 'by desc' or 'by asc' (b_id), however I'd like to be sure.

Thank you.

            Mage


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to