Re: Concatenating string fields with GROUP BY clause

From: "Brian G(dot) Huber" <brianghuber(at)yahoo(dot)com>
To: "Godshall Michael" <Michael_Godshall(at)gmachs(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Concatenating string fields with GROUP BY clause
Date: 2003-09-09 17:29:49
Message-ID: 001701c376f7$fa6af8a0$6400a8c0@bghmobile
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thanks for the response - but II does not seem to work as an aggregate function - for example - if I use:

SELECT groupid, sum(numeric_field), ||(text_field) FROM table GROUP BY groupid

I get

ERROR: Unable to identify a prefix operator '||' for type 'text'
You may need to add parentheses or an explicit cast

Therefore, I think II concatenates two text columns, but does not aggregate. It would seem this is fairly common but there is no text aggregation function listed in 6.14 Aggregate Functions!!!
----- Original Message -----
From: Godshall Michael
To: 'Brian G. Huber' ; pgsql-novice(at)postgresql(dot)org
Sent: Tuesday, September 09, 2003 12:10 PM
Subject: Re: [NOVICE] Concatenating string fields with GROUP BY clause

Concatenate is done with || in postgresql
-----Original Message-----
From: Brian G. Huber [mailto:brianghuber(at)yahoo(dot)com]
Sent: Tuesday, September 09, 2003 12:02 PM
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] Concatenating string fields with GROUP BY clause

Hi -

I am trying to concatenate a text field in a query with a group by clause, similar to a sum() function on a numeric value - for example:

SELECT groupid, sum(numeric_field), ???(text_field) FROM table GROUP BY groupid

but I cannot find a function that will concatenate the text fields. Any comments appreciated!

TIA,BGH

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jeffrey Melloy 2003-09-09 17:52:21 Re: Concatenating string fields with GROUP BY clause
Previous Message Jason Hihn 2003-09-09 17:11:06 Re: Concatenating string fields with GROUP BY clause