Re: order by question - Mailing list pgsql-sql

From Greg Stark
Subject Re: order by question
Date
Msg-id 87mztc7r9r.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: order by question  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
Gary Stainburn <gary.stainburn@ringways.co.uk> writes:

> > Alternatively: (a<>6),(a<>4),a
> 
> Although this does exactly what I want, at first glance it should do 
> exactly the opposite.
> 
> I'm guessing that for each line it evaluates
> not (a=6) 0 for true else 1

Not really, "not a=6" is an expression that evaluates to a boolean, true or
false. true sorts as "greater" than false. That order is counterintuitive but
it's because the default sort order is ascending. So the "lesser" false
records appear first.

If you put "not a=6" in your select column list you'll see the true and false
values appear.


-- 
greg



pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Table like a field
Next
From: Stef
Date:
Subject: Re: [SOLVED] Postgres schema comparison.