Search Postgresql Archives

Re: Order by behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28/03/2007 22:52, Carlos H. Reimer wrote:

SELECT substr(nomerazao,1,4),
ascii(substr(nomerazao,1,1)),
ascii(substr(nomerazao,2,1))
from spunico.unico order by nomerazao;

You need to add aliases to the returned column by which you'd like to order the result: your query is ordering the rows according to the column "nomerazao" in the original table, rather than by the substr() value returned.

Do something like this:

   SELECT substr(nomerazao,1,4) AS my_col,
   ascii(substr(nomerazao,1,1)),
   ascii(substr(nomerazao,2,1))
   from spunico.unico order by my_col;

HTH

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@xxxxxx
---------------------------------------------------------------


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux