Re: help with query: advanced ORDER BY...

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: me(at)alternize(dot)com
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: help with query: advanced ORDER BY...
Date: 2006-01-15 01:38:10
Message-ID: 20060115013810.GA8627@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sat, Jan 14, 2006 at 09:32:03PM +0100, me(at)alternize(dot)com wrote:
> >Something like this might work:
> >
> >SELECT * FROM table1
> >ORDER BY field1,
> > CASE WHEN field1 THEN field2 ELSE NULL END,
> > CASE WHEN field1 THEN field3 ELSE NULL END,
> > CASE WHEN field1 THEN NULL ELSE field3 END,
> > CASE WHEN field1 THEN NULL ELSE field2 END;
>
>
> it indeed does, thanks alot. will pgsql still use the indices when ordering
> through CASE?

I don't think so, unless you define a multicolumn index on those
specific expressions.

Why the different ordering? What are you doing?

--
Michael Fuhr

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message me 2006-01-15 02:15:18 Re: help with query: advanced ORDER BY...
Previous Message me 2006-01-14 20:32:03 Re: help with query: advanced ORDER BY...