Re: Fwd: SELECT MAX with char => BUG?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Fwd: SELECT MAX with char => BUG?
Дата
Msg-id 419F6EA6.1010601@archonet.com
обсуждение исходный текст
Ответ на Fwd: SELECT MAX with char => BUG?  (Rodrigo Carvalhaes <grupos@carvalhaes.net>)
Список pgsql-hackers
Rodrigo Carvalhaes wrote:
> Hi !
> 
> I am quite confused of the results on a SELECT max...
> 
> My environment: Conectiva Linux 10, PostgreSQL 7.4.6 (compiled from
> the sources)
> 
> My problem is the "select max(id) FROM test" the result is 20 but the
>  right is 1020. Is this a BUG or I am crazy ??

Crazy. And posting to the wrong list - try the general/sql lists for 
this sort of thing.

> teste=# CREATE TABLE test ( id char(15), name char(80) ); CREATE

You've defined "id" as char - so it's sorting alphabetically, not 
numerically, so 1111 < 2

Just defined "id" as a numeric type.

--   Richard Huxton  Archonet Ltd


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Trouble with plpgsql on 7.4.6
Следующее
От: Tom Lane
Дата:
Сообщение: Re: New compile warnings