ordering by multiple columns

From: Pablo Barrón <amentoraz(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: ordering by multiple columns
Date: 2007-03-14 15:50:34
Message-ID: d4d13b4c0703140850i4957116bw8a25255131a56346@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi!

I'm trying to order a list in which the first parameter to order is a
specific field, and the second should vary depending on a specific
condition. More explicit, I would like to do something like:

- ORDER BY a.column1, [b.column2 if c.value != 19 || c.column2 if
c.value==19]

That is to say, use a column if a value on each row isn't 19, OR use a
different column if it isn't. How could I solve this? I've got to have a
global order over my query, so I cannot separate it into two queries, etc
:-?

Thank you!

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2007-03-14 15:58:44 Re: import CSV file
Previous Message Wiebe Cazemier 2007-03-14 15:39:42 Joins on many-to-many relations.