Re: Merging rows into one result?

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: Merging rows into one result?
Дата
Msg-id 20060311164337.GA19131@KanotixBox
обсуждение исходный текст
Ответ на Merging rows into one result?  ("Jesper K. Pedersen" <jkp@solnet.homeip.net>)
Ответы Re: Merging rows into one result?  ("Jesper K. Pedersen" <jkp@solnet.homeip.net>)
Список pgsql-sql
Jesper K. Pedersen <jkp@solnet.homeip.net> schrieb:

> Is it possible to use SQL to merge data into one result?
> 
> A theorethical example to explain:
> 
> tbl_test (
>   id integer,
>   information varchar(25))
> 
> id | information
> ---+--------------
> 1  | Yo
> 2  | Go away
> 1  | Stay put
> 3  | Greetings
> 
> Please note id is not unique and not a primary key.
> 
> and I wonder if there is any functions to "merge" data (sort of
> concat'ing).
> A normal: select information from tbl_test where id=1
> would result in the rows
>  Yo
>  Stay put
> 
> I would like a single row result in the format of:
>  Yo Stay put

Yes, of corse, this is possible. You need a own aggregate-function. A
similar example for this task can you find here:

http://www.zigo.dhs.org/postgresql/#comma_aggregate

I think, it is very simple to rewrite this example for your purpose.


HTH, Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°


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

Предыдущее
От: "Jesper K. Pedersen"
Дата:
Сообщение: Merging rows into one result?
Следующее
От: Volkan YAZICI
Дата:
Сообщение: Re: Merging rows into one result?