how to concatenate the value from couple of rows into one column (group by)

as in the tile,  I need one column with  the concatenated values from couple of rows
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary PattersonVP Technology / Senior Consultant Commented:
How about an example of what you want to do?
if it's only from two rows, just use a join to the same table, something like

select t1.columnA || t2.columnb
from your_table t1 join your_table t2 on t1.key = t2.some_column

if you need it from several rows (and you don't know exactly how many, or it's a big number and you don't want the join approach) you will need to either use recursive SQL or write a function for that.

check these questions for the similar problem:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
snigerAuthor Commented:
ok, sorry

so Table 1 is a summary

Customer  year     Codes

xxxx            2014

Table 2 is details

Customer  year  code
xxxx          2014   c1
xxxx          2014   c2

I want in Codes column of table 1 to have :  c1, c2
snigerAuthor Commented:
most of the time it is only 1 code, but it could be more
Tomas Helgi JohannssonCommented:

This should do it ( if you are using version 9.7 or newer )

select t1.customer, t1.year, listagg( t2.code, ',') as code
from table1 t1, table2 t2
where t1.year = t2.year
and t1.customer = t2.customer
group by t1.customer, t1.year

Open in new window

    Tomas Helgi
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.