On Thu, 10 Mar 2016 10:17:57 +0100
Alberto Wu <blu at skylable.com> wrote:
> On 03/09/16 23:30, James K. Lowden wrote:
> >> SELECT P.id FROM (
> >> SELECT 0 AS sect, id FROM t WHERE id >= 'pen'
> >> UNION ALL
> >> SELECT 1, id FROM t WHERE id < 'pen'
> >> ) AS P
> >> ORDER BY P.sect, P.id
> >> ;
> >
> > This is the correct answer.
>
> Hi,
>
> unfortunately the correct answer comes with an extra scan and a temp
> b-tree so I'd rather keep the two queries split and handle the case
> programmatically.
Hmm, does this work any better?
SELECT id FROM t
ORDER BY id < 'pen' desc, id;
--jkl