Search Postgresql Archives

Order by lower(column-alias) doesn't work...

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

 



Hi.
 
This works:
select p.firstname, p.lastname, p.firstname || p.lastname as fullname from onp_crm_person p order by fullname;
 
But this doesn't:
select p.firstname, p.lastname, p.firstname || p.lastname as fullname from onp_crm_person p order by lower(fullname);
ERROR:  column "fullname" does not exist
LINE 1: ... as fullname from onp_crm_person p order by lower(fullname);

 
This is just an example-query, in my real query I have a more complex query generating an array of a custom-type which is then referenced to as a column-alias, and then ORDER BY on a function tranforming this array doesn't work:
 
SELECT ...
ARRAY(WITH RECURSIVE t AS (SELECT
...
SELECT ROW(t.entity_id, t.name)::BigIntVarChar from t order by level DESC) as folder_parent_array
 
 
ORDER BY  bigintvarchar_to_text_value_flatten(folder_parent_array) ASC;
column "folder_parent_array" does not exist
 
What bigintvarchar_to_text_value_flatten() does is to take the "varchar"-part out of the BigintVarchar-type and "flatten" the array by that value so that it sorts nicely.

Any way round this?
 
--
Andreas Joseph Krogh

[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