Hi,
I really need an aggregate function that concatenates the values of a column. Supposing that there was such a function and it was called "CAT", I would be able to use it in the fashion described below.
Suppose I had a table called R:
a | b
======
1 | 'anna'
1 | 'jim'
2 | 'john'
2 | 'mary'
2 | 'jane'
Then the query:
select a, CAT(b) as res
from R
group by a
would give me:
a | res
=======
1 | 'anna jim'
2 | 'john mary jane'
I can't figure out how to define the function CAT in a general fashion (for use in the same way that SUM, COUNT, MAX, etc.) are used since I need somehow for the function to recieve as input several rows of a column!
In Sybase, such an aggregate function exists (called List). In Postgres I can define aggregate functions. I seem stuck in Oracle. Is there anyway to define such aggregate functions in Oracle? Does one exist?
Any help will be greatly appreciated!! (This function is critical in implementing an extension of SQL that is being developed.)
Thanks!
Sara
I really need an aggregate function that concatenates the values of a column. Supposing that there was such a function and it was called "CAT", I would be able to use it in the fashion described below.
Suppose I had a table called R:
a | b
======
1 | 'anna'
1 | 'jim'
2 | 'john'
2 | 'mary'
2 | 'jane'
Then the query:
select a, CAT(b) as res
from R
group by a
would give me:
a | res
=======
1 | 'anna jim'
2 | 'john mary jane'
I can't figure out how to define the function CAT in a general fashion (for use in the same way that SUM, COUNT, MAX, etc.) are used since I need somehow for the function to recieve as input several rows of a column!
In Sybase, such an aggregate function exists (called List). In Postgres I can define aggregate functions. I seem stuck in Oracle. Is there anyway to define such aggregate functions in Oracle? Does one exist?
Any help will be greatly appreciated!! (This function is critical in implementing an extension of SQL that is being developed.)
Thanks!
Sara