• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Select to concat rows

 
Aj Mathia
Ranch Hand
Posts: 478
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic