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. Thanks a lot for your help. -- Alberto

