Re: str_aggr function not wokring

From: aditya desai <admad123(at)gmail(dot)com>
To: Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org>, Patrick(dot)Fiche(at)aqsacom(dot)com
Subject: Re: str_aggr function not wokring
Date: 2021-04-08 12:55:12
Message-ID: CAN0SRDH7q981XcTDsCjhxCceJseF7xqTOYtugooMPfO0p0c9VA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Thanks Patrick. I used WITH Query and feeded that output to string_aggr
which worked. However it is giving performance issues. Will check on that.
THanks.

On Thu, Apr 8, 2021 at 5:11 PM Patrick FICHE <Patrick(dot)Fiche(at)aqsacom(dot)com>
wrote:

> *From:* aditya desai <admad123(at)gmail(dot)com>
> *Sent:* Thursday, April 8, 2021 1:32 PM
> *To:* Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org>
> *Subject:* str_aggr function not wokring
>
>
>
> Hi,
>
> I need to combine results of multiple rows in one row. I get below error.
> Could you please help.
>
>
>
> Query:
>
>
>
> select string_agg((select '******' || P.PhaseName || ' - ' ||
> R.Recommendation AS "ABC" from tblAssessmentRecommendation
> R,tblAssessmentPhases P
>
> where R.PhaseID = P.PhaseID Order BY P.sortOrder DESC),' ')
>
>
>
> Error:
>
>
>
> ERROR: more than one row returned by a subquery used as an expression SQL
> state: 21000
>
>
>
> Regards,
>
> Aditya.
>
>
>
>
>
> Hi,
>
>
>
> I would suggest you to try something like this instead
>
>
>
> select string_agg( '******' || P.PhaseName || ' - ' || R.Recommendation ''
> ORDER BY P.sortOrder DESC ) AS "ABC"
>
> from tblAssessmentRecommendation R,tblAssessmentPhases P
>
> where R.PhaseID = P.PhaseID
>
>
>
> Regards,
>
>
>
> Patrick
>
>
>

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message aditya desai 2021-04-08 12:58:56 Re: str_aggr function not wokring
Previous Message Milos Babic 2021-04-08 12:31:28 Re: procedure using CURSOR to insert is extremely slow