Special ORDER BY

From: Martín Marqués <martin(dot)marques(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Special ORDER BY
Date: 2012-06-19 19:31:44
Message-ID: CABeG9LtRiaAaEULLwxBoud+xcv+HknpFYioUaQYkC2ynq_4t+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How can I order a result set by a special order of a column. For
example, let's say I have this query

SELECT * FROM subcampo sc JOIN campo c ON (c.codigo = sc.campo)
WHERE c.etiqueta IN (245, 130, 240, 243, 246, 490, 630, 730, 740)

Now I want to order the result set using c.etiqueta but with the order
of the values as you see in the IN clause.

How can I do that?

--
Martín Marqués
select 'martin.marques' || '@' || 'gmail.com'
DBA, Programador, Administrador

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tulio 2012-06-19 19:49:37 Re: Special ORDER BY
Previous Message Edson Richter 2012-06-19 19:09:17 Re: Feature discussion: Should syntax errors abort a transaction?