Forums Register Login

SQL Select to concat rows

+Pie Number of slices to send: Send
Hi,
I am trying to achieve the following using sql in oracle
table "xxx"
namevalue
a 1
a 2
a 3
b 4
b 5

select name, (string concat of values ie 1,2,3)
from xxx
where name in('a','b')

Resulting in
a 123
b 45
+Pie Number of slices to send: Send
Off hand I'd say you would need a stored procedure to do it purely on the database side since your concat is on the same field an unknown number of times.

This isn't the kind of item a DBMS handles particularly well so I'd suggest a middle tier solution if possible such as using the ResultSet class and building a HashSet of results or something.
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1248 times.
Similar Threads
concatination of 3 fields in SQL query
Query of Oracle to SQL Server
xsl:param and xsl:copy-of
Selecting data from multiple tables
Tech Word Game
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:26:43.