0

i have the following query(SQL)

select  x from Test
group by x
having  count(x)>1;

i want to concatenate the result in one row, any idea. note: for simple query i have user wm_concat function and it works fine, but it does not work for above query may be because grouping.

any help please?

user272735
  • 10,473
  • 9
  • 65
  • 96
user3258052
  • 59
  • 1
  • 2
  • 7
  • possible duplicate of [how to retrieve two columns data in A,B format in Oracle](http://stackoverflow.com/questions/12145379/how-to-retrieve-two-columns-data-in-a-b-format-in-oracle) or [this](http://stackoverflow.com/questions/4686543/sql-query-to-concatenate-column-values-from-multiple-rows-in-oracle) or [this](http://stackoverflow.com/questions/1120706/is-there-an-oracle-sql-query-that-aggregates-multiple-rows-into-one-row) – A.B.Cade Feb 04 '14 at 12:16

1 Answers1

0

Here is a way that you can do it. Note that I have included an argument in the listagg function to add in a comma as the delimiter, this can be excluded or changed as needed:

select listagg(x, ',') 
         within group (order by x) as concatenated_result
  from (select x 
          from Test
         group by prxod_id 
         having count(x)>1
          );
ChrisProsser
  • 12,598
  • 6
  • 35
  • 44