Re: Need to overcome UNION / ORDER BY restriction

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Need to overcome UNION / ORDER BY restriction
Дата
Msg-id 20030929171503.GA10856@wolff.to
обсуждение исходный текст
Ответ на Need to overcome UNION / ORDER BY restriction  ("Timo" <siroco@suomi24.fi>)
Список pgsql-sql
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 |       271935 |        1 |       276924 |        1 |       581902 |
2|       271902 |        3 |       271972 |        2 |       275935 |        2 |       276924 |        2 |       581924
|       3 |       581
 
(9 rows)


В списке pgsql-sql по дате отправления:

Предыдущее
От: Doris Bernloehr
Дата:
Сообщение: SQL Syntax problem
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: postgres index on ILIKE