Re: str_aggr function not wokring

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.Fiche@xxxxxxxxxxx> wrote:

From: aditya desai <admad123@xxxxxxxxx>
Sent: Thursday, April 8, 2021 1:32 PM
To: Pgsql Performance <pgsql-performance@xxxxxxxxxxxxxxxxxxxx>
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

 


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux