From: | Andreas Joseph Krogh <andreas(at)visena(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Order by lower(column-alias) doesn't work... |
Date: | 2020-05-28 12:14:41 |
Message-ID: | VisenaEmail.2b.86f8bc58bbd29c56.1725b2fd4cc@tc7-visena |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Marco Lechner | 2020-05-28 12:24:53 | AW: Linux Update Experience |
Previous Message | Zwettler Markus (OIZ) | 2020-05-28 11:42:20 | AW: Linux Update Experience |