Hi,
For H2, if you run "select x", this is expanded to "select x from dual". Therefore, this "x" is not referring to the outer "x". Could you use: select x from ( select 1 x union select 2 union select 3 ) t order by (select -t.x) asc Regards, Thomas On Friday, August 22, 2014, Lukas Eder <[email protected]> wrote: > Hello, > > The following query doesn't work correctly in H2: > > select x from ( > select 1 x union > select 2 union > select 3 > ) t > order by (select -x) asc > > > The above should return > > +----+ > | X| > +----+ > | 3| > | 2| > | 1| > +----+ > > > But instead returns: > > +----+ > | X| > +----+ > | 1| > | 2| > | 3| > +----+ > > > For the record, this query returns the correct result: > > select x from ( > select 1 x union > select 2 union > select 3 > ) t > order by -x asc > > > Cheers, > Lukas > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
