From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Andreas Joseph Krogh <andreas(at)visena(dot)com> |
Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Re: Is ORDER BY in sub-query preserved when outer query is only projection? |
Date: | 2018-01-15 18:04:51 |
Message-ID: | CAKFQuwbmGjSvP=Kv1Yz_gNUOemHag_JQoS8tuaYrztqwuG_DEQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, Jan 14, 2018 at 5:40 AM, Andreas Joseph Krogh <andreas(at)visena(dot)com>
wrote:
> På søndag 14. januar 2018 kl. 13:30:29, skrev Francisco Olarte <
> folarte(at)peoplecall(dot)com>:
>
> Andreas:
>
> On Sun, Jan 14, 2018 at 1:03 PM, Andreas Joseph Krogh
> <andreas(at)visena(dot)com> wrote:
> > SELECT q.* FROM (
> > SELECT comp.id, comp.name
> > FROM company comp JOIN req r ON r.company_id = comp.id
> > ORDER BY LOWER(comp.name) ASC
> > ) AS q
> > ORDER BY r.status ASC
>
>
> Do you see any solution sorting on a composite type without using an outer
> query?
>
>
Tacking on ORDER BY to an inner query is generally not the right thing to
do.
What can you not write:
SELECT q.* FROM () AS q
ORDER BY lower(q.name) ASC, q.status ASC
?
Also, ORDER BY r.status ASC in you original query shouldn't work - r is not
visible at that point, only q is.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Joseph Krogh | 2018-01-15 18:10:22 | Sv: Re: Re: Is ORDER BY in sub-query preserved when outer query is only projection? |
Previous Message | Haroldo Stenger | 2018-01-15 17:48:00 | Re: Re: Is ORDER BY in sub-query preserved when outer query is only projection? |