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 [EMAIL PROTECTED] --------------------------------------------------------------- ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq