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.