Re: table linking problem

Поиск
Список
Период
Сортировка
От Holger Klawitter
Тема Re: table linking problem
Дата
Msg-id 200210071651.47143.lists@klawitter.de
обсуждение исходный текст
Ответ на table linking problem  ("¼B¤tºÆ" <jacky@xtrapower.net>)
Список 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@klawitter.de

В списке pgsql-general по дате отправления:

Предыдущее
От: "Shridhar Daithankar"
Дата:
Сообщение: Re: [pgsql-performance] Large databases, performance
Следующее
От: Tom Lane
Дата:
Сообщение: Re: psql: relocation error: psql: undefined symbol: PQgetssl