Re: order by question

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: order by question
Date: 2005-03-09 15:50:08
Message-ID: 87mztc7r9r.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stef 2005-03-09 17:19:14 Re: [SQL] [SOLVED] Postgres schema comparison.
Previous Message Bruno Wolff III 2005-03-09 14:26:11 Re: order by question