On Wed, 9 Mar 2016 20:43:14 +0200
R Smith <rsmith at rsweb.co.za> 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.  

I'm not sure what you meant by "axiom" in your earlier post.  To the
best of my knowledge, UNION ALL makes no promise about order (and
standard SQL proscribes ORDER BY in a subquery).  If the implementation
finds it more efficient, for instance, to send alternating rows from
each element in the union, it's free to do so.  

--jkl

Reply via email to