[SQL] How to collect text-fields from multiple rows ?

2010-10-15 Thread Andreas
Hi, how can I collect text-fields from multiple rows into one output row? I'd like to do an equivalent to the aggregate function SUM() only for text. The input is a select that shows among other things a numerical column where I would like to group by. The text column of all rows in a group sh

Re: [SQL] counting related rows

2010-10-15 Thread James Cloos
After further though, I tried using a function: CREATE OR REPLACE FUNCTION children ( ow integer, parent text) returns integer AS $$ select count(*) as children from m where o = $1 and name ilike $2 || '/%'; $$ LANGUAGE sql; An example call is: select o, name, f1, f2, (select children(o,name) a