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

From: Andreas Joseph Krogh <andreas(at)visena(dot)com>
To: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Order by lower(column-alias) doesn't work...
Date: 2020-05-28 12:55:55
Message-ID: VisenaEmail.31.f9b7c96fd0fa46d2.1725b5848c8@tc7-visena
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


På torsdag 28. mai 2020 kl. 14:50:54, skrev Geoff Winkless <pgsqladmin(at)geoff(dot)dj
<mailto:pgsqladmin(at)geoff(dot)dj>>:
On Thu, 28 May 2020 at 13:14, Andreas Joseph Krogh <andreas(at)visena(dot)com> wrote:
> 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);

Wrap the original query in either a CTE or a temporary table.
eg
[..]

Yea, I was hoping to avoid that, as the query is generated and rewriting it is
a pain...

Is there a way to define "sorting-rules" on custom-types so that I can have
ORDER BY <my_array_of_custom_types_alias> and PG will pick my custom odering?

--
Andreas Joseph Krogh

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2020-05-28 13:26:42 Re: Order by lower(column-alias) doesn't work...
Previous Message Geoff Winkless 2020-05-28 12:50:54 Re: Order by lower(column-alias) doesn't work...