From: Bruno Wolff III <bruno@wolff.to>
To: Timo <siroco@suomi24.fi>
Cc: pgsql-sql@postgresql.org
Subject: Re: Need to overcome UNION / ORDER BY restriction
Date: Mon, 29 Sep 2003 12:15:03 -0500
Message-ID: <20030929171503.GA10856@wolff.to> (raw)
In-Reply-To: <bl9fh3$1krk$1@news.hub.org>
References: <bl9fh3$1krk$1@news.hub.org>
On Mon, Sep 29, 2003 at 17:27:47 +0300,
Timo <siroco@suomi24.fi> wrote:
>
> I'd need to get a result set where rows are sorted according to these rules:
>
> 1. first all rows with priority = 1 sorted according to seniority
> 2. then the rest of the rows sorted by seniority, priority
You can do something like:
bruno=> select * from foo order by priority <> 1, seniority, priority;
id | priority | seniority
-----+----------+-----------
902 | 1 | 271
935 | 1 | 276
924 | 1 | 581
902 | 2 | 271
902 | 3 | 271
972 | 2 | 275
935 | 2 | 276
924 | 2 | 581
924 | 3 | 581
(9 rows)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bruno@wolff.to, siroco@suomi24.fi
Subject: Re: Need to overcome UNION / ORDER BY restriction
In-Reply-To: <20030929171503.GA10856@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox