Ordenar resultado por números en campo varchar

From: Rodrigo Ruiz <rruizf(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Ordenar resultado por números en campo varchar
Date: 2010-09-30 16:22:14
Message-ID: 4CA4B936.4030305@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Estimados,
la siguiente representa parte del resultado de una consulta sobre una
tabla y que se ordena por el campo 'indice' de forma ascendente.

# select * from tabla order by indice asc;

id | titulo | indice
----+----------+--------
106 | texto 4 | 1.1
115 | texto 13 | 1.10
116 | texto 1 | 1.11
107 | texto 5 | 1.2
108 | texto 6 | 1.3
109 | texto 7 | 1.4
110 | texto 8 | 1.5
111 | texto 9 | 1.6
112 | texto 10 | 1.7
113 | texto 11 | 1.8
114 | texto 12 | 1.9
117 | texto 2 | 2.1
118 | texto 3 | 2.2

El campo indice es un varchar, si notan, luego del punto 1.1 salta al
1.10, el cual necesito se presente siguiendo al punto 1.9.
Intenté pasando el campo a numérico con cast, sin embargo se me
complicó, pues podrían existir puntos del tipo 1.2.6 o más detallado aún.
La pregunta ya la podrán adivinar, cómo podría obtener el resultado de
la consulta de manera ordenada por índice?

Saludos cordiales.-

--
Rodrigo Ruiz Fuentes

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Miguel Angel Hernandez Moreno 2010-09-30 16:26:37 Re: [pgsql-es-ayuda] Ordenar resultado por números en campo varchar
Previous Message Lennin Caro 2010-09-30 16:21:36 Re: Problemas de instalacion de Postgresql 8.2 en Debian Lenny 64bits