Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 858099FBBA8 for ; Wed, 14 Mar 2007 12:50:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 54035-05 for ; Wed, 14 Mar 2007 12:50:35 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by postgresql.org (Postfix) with ESMTP id 6C94B9FBB8F for ; Wed, 14 Mar 2007 12:50:36 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id x4so274427nfb for ; Wed, 14 Mar 2007 08:50:34 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=d0acl8xQ4gBRNKlgI7Mnt5m1VBitPNEZKnVCbSJOML3M3skjC8dNgHyYAc2zkTmUCAiYYXTWM2dQpIO/3dcV4lmtKZZJAxSRemh6FNKe2UyI+YktTiJpuiaCcbw/Msew/Zuul5GSxXXHdPtqmod56eZQIhYbFmkpKUOTfZ1wTJE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=mytRKxH1uo+/i80p5TPmrROl1Cvhqzz7ELLDgEb1sNrsew3sv/4aOj3woEcWqtwjlcsggK409mt91udthfGIztgdgfyEQRYAwK1mfoeMa4BHAlEIFhimXMi97BwN8V8ulOzfPCVdgtVOZ4NbroLuZLfJrEnJT3nWhCXQiM2xNF0= Received: by 10.78.193.5 with SMTP id q5mr1269886huf.1173887434221; Wed, 14 Mar 2007 08:50:34 -0700 (PDT) Received: by 10.82.116.10 with HTTP; Wed, 14 Mar 2007 08:50:34 -0700 (PDT) Message-ID: Date: Wed, 14 Mar 2007 16:50:34 +0100 From: "=?ISO-8859-1?Q?Pablo_Barr=F3n?=" To: pgsql-sql@postgresql.org Subject: ordering by multiple columns MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_30981_26198747.1173887434179" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/198 X-Sequence-Number: 27836 ------=_Part_30981_26198747.1173887434179 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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! ------=_Part_30981_26198747.1173887434179 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
 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!


------=_Part_30981_26198747.1173887434179--