Order by lower(column-alias) doesn't work... - Mailing list pgsql-general

From Andreas Joseph Krogh
Subject Order by lower(column-alias) doesn't work...
Date
Msg-id VisenaEmail.2b.86f8bc58bbd29c56.1725b2fd4cc@tc7-visena
Whole thread Raw
Responses Re: Order by lower(column-alias) doesn't work...
List pgsql-general
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

pgsql-general by date:

Previous
From: "Zwettler Markus (OIZ)"
Date:
Subject: AW: Linux Update Experience
Next
From: Marco Lechner
Date:
Subject: AW: Linux Update Experience