Re: problem with sorting using 'ORDER BY' when character field is filled with numerical values
В списке pgsql-general по дате отправления:
| От | Thomas Beutin |
|---|---|
| Тема | Re: problem with sorting using 'ORDER BY' when character field is filled with numerical values |
| Дата | |
| Msg-id | 20040521001447.A1289@laokoon.bug.net обсуждение |
| Ответ на | problem with sorting using 'ORDER BY' when character field is filled with numerical values (Dragan Matic <mlists@panforma.co.yu>) |
| Список | pgsql-general |
On Thu, May 20, 2004 at 05:18:39PM +0200, Dragan Matic wrote: > If I have a table t with column c which is defined as char(5) and fill > it with following values: [...] > and then do the following: SELECT C FROM T ORDER BY C > Postgres gives me the following > > 1 > 11 > 12 > 14 > 2 [...] > the same thing done with MS SQL server gives this as a result: [...] > which is the result I find more logical, meaning the user would expect > data sorted this way. Is there some way to make Postgres sort elements no, the first is the logical if You sort a char(5) field. > in this way (setting sort order or collation, I suppose)? Tnx in advance You should try an "ORDER BY to_number(<your_column>, '99999')" Greetings, -tb -- Thomas Beutin tb@laokoon.IN-Berlin.DE Beam me up, Scotty. There is no intelligent live down in Redmond.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера