Search Postgresql Archives

Re: Seemingly inconsistent ORDER BY behavior

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

 




On Wed, 2013-08-14 at 14:01 -0400, Richard Hipp wrote:
> CREATE TABLE t1(m VARCHAR(4));
> INSERT INTO t1 VALUES('az');
> INSERT INTO t1 VALUES('by');
> INSERT INTO t1 VALUES('cx');
> 
> SELECT '1', substr(m,2) AS m
>   FROM t1
>  ORDER BY m;
> 
> SELECT '2', substr(m,2) AS m
>   FROM t1
>  ORDER BY lower(m);


You cannot cast your ORDER BY column value.

Instead:-

SELECT '2', LOWER(substr(m,2)) AS m
FROM t1
ORDER BY m;

will have the desired effect.



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[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