Subject Re: Sum (concat?) equivalent for Strings
Author Adam
--- In firebird-support@yahoogroups.com, "Scott Buckham"
<scott_buckham@a...> wrote:
> I'm looking for a function that will return me a concatenation of
> Strings found across multiple rows. E.g like where you can use
> sum(NumericColumn) to return value 10 for rows 5,5 I want to be
able to
> use functionX(StringColumn) to return "AB" for rows A,B.
>
> Is this achievable?


If you mean you have a single field with multiple rows

field1
A
B

then you could write a stored procedure to do the concatination

create procedure sp_blah
returns
(
outputstring varchar(500); -- make sure this is large enough
)
as
declare variable field1 varchar(10);
begin
outputstring = '';
for select field1 from tablea into :field1 do
begin
outputstring = :outputstring || :field1;
end

suspend; -- only if you use it as a selectable SP
end
^

So it is possible, but these transformations are generally much
easier on the client side.

Adam