1

I have a table named Dummy as shown below:

No.   Name
1     ABC
2     NMD
2     SDSDS
1     23ererer

Now i wanted to concat all Name column with a given number

For ex. say No. is 1 i want ABC23ererer as my output

This is to be done in ORACLE(SQL) without using PL-SQL.

How can this be done?

Mayank Jain
  • 2,504
  • 9
  • 33
  • 52

4 Answers4

1

this might help...

select NO,
  listagg(NAME, ',') within group (order by NAME) as name
from TableName
group by NO

Or else check this

Gopesh Sharma
  • 6,730
  • 4
  • 25
  • 35
1

LISTAGG is not supported in oracle10g. If you have 10g i think the following query will help you.

select No, rtrim(Name,',') Name
       from ( select No
      , Name, rn
         from yourtable
               model
                      partition by (No)
                        dimension by (row_number() over
                                     (partition by No order by Name) rn
                                    )
                       measures     (cast(Name as varchar2(40)) Name)
                       rules
                       ( Name[any] order by rn desc = Name[cv()]||''||Name[cv()+1]
                       )
              )
        where rn = 1
        order by NO

see for your demo in sql fiddle

Dinup Kandel
  • 2,457
  • 4
  • 21
  • 38
  • you have ask's tom `stragg` since 9i [here](http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:15637744429336) – haki Jul 04 '13 at 06:13
0
SELECT "No.", LISTAGG(Name, ',') WITHIN GROUP (ORDER BY "No.") AS Name
FROM TableName
GROUP BY "No.";
Devart
  • 119,203
  • 23
  • 166
  • 186
-4

try this :

SELECT Number+' '+
Name FROM table_name 

Ahmed
  • 452
  • 3
  • 7