ORDER BY custom type

Поиск
Список
Период
Сортировка
От Andreas Joseph Krogh
Тема ORDER BY custom type
Дата
Msg-id VisenaEmail.167.abde9aaf9b1c0c53.160e4d866b9@tc7-visena
обсуждение исходный текст
Ответы Sv: ORDER BY custom type  (Andreas Joseph Krogh <andreas@visena.com>)
Список pgsql-general
Hi all.
 
I have this custom-type:
 
CREATE TYPE PERSONTYPE AS
(    id        BIGINT,    firstname VARCHAR,    lastname  VARCHAR,    initials  VARCHAR
);
 
I'm returning a column with this type using the following query, which lists activities and its responsible-person (using the PERSONTYPE):
SELECT act.entity_id AS project_id, act.name AS project    , (SELECT ROW(p.entity_id, p.firstname, p.lastname, p.initials)::persontype        FROM onp_crm_person p        WHERE act.responsible = p.onp_user_id) AS responsible_person
from onp_crm_activity act
ORDER BY responsible_person ASC
;
 
But I need to ORDER BY different properties of PERSONTYPE, ie. initials, and am wondering if there exists a mechanism to achieve the following:
SELECT act.entity_id AS project_id, act.name AS project    , (SELECT ROW(p.entity_id, p.firstname, p.lastname, p.initials)::persontype        FROM onp_crm_person p        WHERE act.responsible = p.onp_user_id) AS responsible_person
from onp_crm_activity act
ORDER BY responsible_person.initials ASC
;
How do I do that?
 
Thanks.
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Francisco Olarte
Дата:
Сообщение: Re: String comparison problem in select - too many results
Следующее
От: Durumdara
Дата:
Сообщение: Re: String comparison problem in select - too many results