Re: table linking problem

From: Holger Klawitter <lists(at)klawitter(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: table linking problem
Date: 2002-10-07 14:51:47
Message-ID: 200210071651.47143.lists@klawitter.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> The Question is,
> How can I get like this :
> 100% COTTON
> 63.5% POLYESTER 31.5% NYLON 5% SPANDEX
>
> Can I return the string like this ?

Yes, it can be done with plpgsql.

You need the group operation and create an aggregate like this:

create function str_append( text, text ) returns text as '
begin
if $1 isnull then
return $2;
else
return $1 || '' '' || $2;
end if;
end;' language 'plpgsql';

create aggregate str_concat (
basetype = text,
sfunc = str_append,
stype = text
);

select str_concat( c.percentage || ' ' || m.name )
from content c, material m
where c.material_id = m.material_id
group by c.content_id;

With kind regards / mit freundlichem Gruß
Holger Klawitter
--
Holger Klawitter http://www.klawitter.de
lists(at)klawitter(dot)de

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-10-07 14:54:06 Re: psql: relocation error: psql: undefined symbol: PQgetssl
Previous Message Shridhar Daithankar 2002-10-07 14:39:55 Re: [pgsql-performance] Large databases, performance