merge multiple records into 1

Поиск
Список
Период
Сортировка
Искать

merge multiple records into 1

От:
"Brian Maguire" <bmaguire@vantage.com>
Дата:
What would be the best way to "flatten" a set of records into one column with a query? 

example:

You have a table called tbletters

id letters
1      a
2      b
3      c
4      d

So I can return this as one column in one record

a,b,c,d 

 

 

 

Re: merge multiple records into 1

От:
Bruno Wolff III <bruno@wolff.to>
Дата:
On Sat, Aug 23, 2003 at 20:16:51 -0400,
  Brian Maguire  wrote:
> What would be the best way to "flatten" a set of records into one column with a query? 
> 
> example:
> 
> You have a table called tbletters
> 
> id letters
> 1      a
> 2      b
> 3      c
> 4      d
> 
> So I can return this as one column in one record
> 
> a,b,c,d 

You could write an aggregate function that concatenates strings. There should
even be examples of some code that does this in the archives from within
the last 6 months.

Re: merge multiple records into 1

От:
CoL <col@mportal.hu>
Дата:
Hi,

how about tablefunc_crosstab from contrib/tablefunc ?

Brian Maguire wrote, On 8/24/2003 2:16 AM:
> What would be the best way to "flatten" a set of records into one column with a query? 
> 
> example:
> 
> You have a table called tbletters
> 
> id letters
> 1      a
> 2      b
> 3      c
> 4      d
> 
> So I can return this as one column in one record
> 
> a,b,c,d 
C.

FAQ