PostgreSQL Сопоставление сервисов к типам заявок
SELECT
s."Id" AS ServiceId,
(xpath('//*[local-name()!="Language"]/text()', s."NameXml"))[1]::text AS ServiceName,
tt."Id" AS TaskTypeId,
(xpath('//*[local-name()!="Language"]/text()', tt."NameXml"))[1]::text AS TaskTypeName
FROM "ServiceTaskType" stt
JOIN "Service" s ON stt."ServiceId" = s."Id"
JOIN "TaskType" tt ON stt."TaskTypeId" = tt."Id"
ORDER BY
(xpath('//*[local-name()!="Language"]/text()', s."NameXml"))[1]::text,
(xpath('//*[local-name()!="Language"]/text()', tt."NameXml"))[1]::text;