[sqlite] How to order by absolute value ?

2016-04-05 Thread R Smith
On 2016/04/05 11:48 AM, Niall O'Reilly wrote: > On 5 Apr 2016, at 10:06, Graham Holden wrote: > >> Change "select abs(num)" in your second example to "select num" and >> you should be good. I'm guessing in your first example the ORDER BY >> only applies to the last SELECT. > > I expect you're

[sqlite] How to order by absolute value ?

2016-04-05 Thread Niall O'Reilly
On 5 Apr 2016, at 10:59, R Smith wrote: > > The documentation is correct and the fault is not that the ORDER BY > did not only apply to the last select - the problem is more that the > ORDER BY abs(num) did not know that "num" is a valid column name in > the compound select - which seems under

[sqlite] How to order by absolute value ?

2016-04-05 Thread Domingo Alvarez Duarte
? Thank you for reply ! Yes it works ! > Tue Apr 05 2016 11:06:52 AM CEST from "Graham Holden" > Subject: Re: [sqlite] How to order by absolute >value >? > > Change "select abs(num)" in your second example to "select num" and you >sho

[sqlite] How to order by absolute value ?

2016-04-05 Thread Domingo Alvarez Duarte
Thank you for reply ! Yes it works ! > Tue Apr 05 2016 11:12:03 AM CEST from "R Smith" >Subject: Re: [sqlite] How to order by absolute value ? > > On 2016/04/05 10:47 AM, Domingo Alvarez Duarte wrote: > >>Hello ! >> >> I want to achieve this:

[sqlite] How to order by absolute value ?

2016-04-05 Thread R Smith
On 2016/04/05 10:47 AM, Domingo Alvarez Duarte wrote: > Hello ! > > I want to achieve this: > > select 1 as num > union > select 3 as num > union > select -2 as num > > order by abs(num) -- result [1, -2, 3] > > But it doesn't work this works but doesn't show what I want: > > select abs(num) > fr

[sqlite] How to order by absolute value ?

2016-04-05 Thread Niall O'Reilly
On 5 Apr 2016, at 10:06, Graham Holden wrote: > Change "select abs(num)" in your second example to "select num" and > you should be good. I'm guessing in your first example the ORDER BY > only applies to the last SELECT. I expect you're right, but https://www.sqlite.org/lang_select.html see

[sqlite] How to order by absolute value ?

2016-04-05 Thread Domingo Alvarez Duarte
Hello ! I want to achieve this: select 1 as num union select 3 as num union select -2 as num order by abs(num) -- result [1, -2, 3] But it doesn't work this works but doesn't show what I want: select abs(num) from ( select 1 as num union select 3 as num union select -2 as num ) order

[sqlite] How to order by absolute value ?

2016-04-05 Thread Graham Holden
Date: 05/04/2016 09:47 (GMT+00:00) To: SQLite mailing list Subject: [sqlite] How to order by absolute value ? Hello !? I want to achieve this:? select 1 as num union select 3 as num union select -2 as num order by abs(num) -- result [1, -2, 3]? But it doesn't work this work