Skip site navigation (1) Skip section navigation (2)

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

From: <me(at)alternize(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: help with query: advanced ORDER BY...
Date: 2006-01-14 20:32:03
Message-ID: 011601c61949$9660a160$6402a8c0@iwing (view raw or flat)
Thread:
Lists: pgsql-novice
> 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?

cheers,
thomas 



In response to

Responses

pgsql-novice by date

Next:From: Michael FuhrDate: 2006-01-15 01:38:10
Subject: Re: help with query: advanced ORDER BY...
Previous:From: Michael FuhrDate: 2006-01-14 17:18:29
Subject: Re: help with query: advanced ORDER BY...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group