Re: sort by on two columns

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: sort by on two columns
Дата
Msg-id 2E86574A-3D96-11D8-A298-000A95C88220@myrealbox.com
обсуждение исходный текст
Ответ на sort by on two columns  ("Andy Lewis" <jumboc@comcast.net>)
Ответы Re: sort by on two columns
Список pgsql-sql
Hi Andy,

On Jan 2, 2004, at 7:15 PM, Andy Lewis wrote:

> Is it possible to sort by two columns? Using the query below?
>
> SELECT table1.name, table2.name, <other selected columns> FROM table1,
> table2 WHERE table1.id = table2.id ORDER BY <what?>
>
> I want to be able to sort the names select from two different tables 
> and
> two different colums(same data type).


If you want to order by table1.name and table2.name, just enter them in 
a comma-separated-list after ORDER BY, e.g.,

SELECT table1.name, table2.name, <other selected columns>
FROM table1, table2
WHERE table1.id = table2.id
ORDER BY table1.name, table2.name

Check out the following link for the online docs:
<http://www.postgresql.org/docs/current/static/queries-order.html>

It doesn't explicitly give you an example of sorting on more than one 
column, but the syntax explanation at the top includes it.

Does this help?

Michael Glaesemann
grzm myrealbox com



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

Предыдущее
От: Bertrand Petit
Дата:
Сообщение: Re: Ambiguous error message
Следующее
От: "Andy Lewis"
Дата:
Сообщение: Re: sort by on two columns