Re: numerical sort on mixed alpha/numeric data

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: numerical sort on mixed alpha/numeric data
Дата
Msg-id 20030716164106.GC1263@wolff.to
обсуждение исходный текст
Ответ на numerical sort on mixed alpha/numeric data  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Ответы Re: numerical sort on mixed alpha/numeric data  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-sql
On Wed, Jul 16, 2003 at 12:48:26 +0100, Gary Stainburn <gary.stainburn@ringways.co.uk> wrote:
> Hi folks,
> 
> I've got a table holding loco numbers and an id which references the locos 
> table. How can I sort this table, so that numeric values appear first in 
> numerical order followed by alpha in alpha order.?

You can first sort by whether or not a pattern match succeeds. You haven't
said whether or not the empty string is a number or an alpha and that will
affect the choice of pattern.

For example:
select * from lumbers order by lumber !~ '^[0-9]+$', lumber;


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

Предыдущее
От: Dani Oderbolz
Дата:
Сообщение: Re: Data Warehousing
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: numerical sort on mixed alpha/numeric data