ORDER BY elements in ARRAY

From: Andreas Joseph Krogh <andreas(at)visena(dot)com>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: ORDER BY elements in ARRAY
Date: 2024-08-27 11:22:49
Message-ID: VisenaEmail.11.efc8bf0cbc6c75fa.1919390a6d7@origo-test01.app.internal.visena.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi, I have this query:

SELECT comp.entity_id as company_id, comp.companyname AS company_name , ARRAY(
SELECT (pers.entity_id , pers.firstname , pers.lastname )::PersonTypeTest FROM
onp_crm_person AS pers WHERE pers.relation_id = comp.entity_id ) as
person_array FROM onp_crm_relation comp ORDER BY person_array ;

And I'd like to ORDER BY (conceptually) lower(pers.firstname),
lower(pers.lastname). I realize there might be more than 1 person in the array,
so I'd like to order by “firstname and lastname of first element, the same for
second etc.”

Any way to do this?

--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
andreas(at)visena(dot)com <mailto:andreas(at)visena(dot)com>
www.visena.com <https://www.visena.com>
<https://www.visena.com>

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Guillaume Lelarge 2024-08-27 11:44:02 Re: ORDER BY elements in ARRAY
Previous Message Frank Komsic 2024-08-19 17:16:05 Re: Powerfailure caused a reduction in INSERT performance of version 12 database.