Re: please need help: alpha numeric sorting
От | Markus Wollny |
---|---|
Тема | Re: please need help: alpha numeric sorting |
Дата | |
Msg-id | 2266D0630E43BB4290742247C8910575014CE32B@dozer.computec.de обсуждение исходный текст |
Ответ на | please need help: alpha numeric sorting ("Raouf" <aimeur@prodigy.net>) |
Список | pgsql-novice |
Hello!
The resulting sorting order is quite correct in terms of alphanumeric sorting. If you want numeric sorting, you would probably need to separate the leading number from the tailing string, so you had two fields e.g. "chapter_nr" of type float4 and "chapter_title" of type text (if that's what it is). Then you could just order by chapter_nr and would get a numerically correct sort instead of the alphanumerically correct sort. Alphanumeric always goes character per character from left to right and therefore n.11 is coming before n.2 - the tailing 1 after the first 1 doesn't matter, because n.11 is not regarded as n, point and eleven but n, point and two ones in sequence.
Regards,
Markus
-----Ursprüngliche Nachricht-----
Von: Raouf [mailto:aimeur@prodigy.net]
Gesendet: Freitag, 2. August 2002 10:49
An: pgsql-novice@postgresql.org
Betreff: [NOVICE] please need help: alpha numeric sortingHi Gurus,I need your help for this one:let's say I have 1 field of type VARCHAR that contains numbers (as ascii) and characters like this:title-----------12.1 cisco ccnp routing12.2 cisco ccnp remote access12.11cisco ccnp switching12.3 cisco ccnp supportI'd like to sort that column in alphanumeric order, like this:title-----------12.1 cisco ccnp routing12.2 cisco ccnp remote access12.3 cisco ccnp support12.11cisco ccnp switchingbut if I sort using group by title and order by title asc I have:title-----------12.1 cisco ccnp routing12.11cisco ccnp switching12.2 cisco ccnp remote access12.3 cisco ccnp support12.11cisco ccnp switchingwhere "12.11cisco ccnp switching" is before "12.2 cisco ccnp remote access" because it is smaller.Is it possible ?thanks for your help
В списке pgsql-novice по дате отправления: