Re: Turning column into row - Mailing list pgsql-sql

From Tille, Andreas
Subject Re: Turning column into row
Date
Msg-id Pine.LNX.4.44.0205231119570.8932-100000@wr-linux02.rki.ivbb.bund.de
Whole thread Raw
In response to Re: Turning column into row  ("Joel Burton" <joel@joelburton.com>)
Responses Re: Turning column into row  ("Joel Burton" <joel@joelburton.com>)
List pgsql-sql
On Wed, 22 May 2002, Joel Burton wrote:

> http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=13
> 9 will do as a LIST() replacement.
While beeing a great hint it has a syntactical mistake.

The correct syntax would be:

-- creat function to comma-ify a list

create function comma_aggregate(text,text) returns text as '
begin if (length($1) > 0 ) then   return $1 || '', '' || $2;   /* note the '' here !! */ else   return $2; end if;
end;
' language 'plpgsql';


A further question:  Is there any possibility to add a further flag in the
way:
  select fname, lname, comma(hobbies,SPORT_FLAG) from people join hobbies on (personid) group by personid, fname,
lname,SPORT_FLAG;
 

So that we get only those hobbies listed which have SPORT_FLAG = 1
or something else?

Kind regards
       Andreas.


pgsql-sql by date:

Previous
From: Denis
Date:
Subject: Re: Further info : Very high load average but no cpu utilization ?
Next
From: rhema@bhasin.co.in
Date:
Subject: ...