Answer the question
In order to leave comments, you need to log in
How to make a cleaner pgsql query without joins?
Good day!
select cons."Custom".*,
array_agg(cons."PTarget"."Name" || ': ' || cons."SLine"."Quantity") as Prices
FROM cons."Custom"
JOIN cons."Subscr" on cons."Subscr"."Custom" = cons."Custom"."Id"
JOIN cons."SLine" on cons."Subscr"."Id" = cons."SLine"."Subscr"
JOIN cons."Price" on cons."SLine"."PriceId" = cons."Price"."Id"
JOIN cons."PTarget" on cons."PTarget"."Id" = cons."Price"."TargetId"
WHERE cons."Subscr"."Status" in ('New')
GROUP BY cons."Custom"."Id";
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question