Link to home
Start Free TrialLog in
Avatar of diteps06
diteps06Flag for United States of America

asked on

Concatenate values of a column

I have a table Company with columns like Phone_Num, Fax and email where they can have multiple values.
These values should be return in a single row.
The table below shed more light on the scenario
Company | Phone_Num | Fax | email
AG             0345             45       ab@rt.com
AG             0378             47      ab@rt.com
GB             0256            34       gb@rt.com
GB            0298             34       gb2@rt.com
RD            0449              67       rd@rt.com

I would the result of my query be

Company | Phone_Num | Fax   | email
AG              0345,0378   45,47   ab@rt.com
GB               0256,0256   34       gb@rt.com,gb2@rt.com
RD                    0449        67       rd@rt.com

I am thinking of creating a function given the name of the company, it returns a
string in the pattern the "Phone_NUm#Fax&email". Using string functions like substring and length
I would split it in the respective variables.
My problem is how can I create the oracle function.
Any help would be welcome.
SOLUTION
Avatar of fmonroy
fmonroy
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of diteps06

ASKER

I would like to have a solution the to the proposal I made. Your solution is good but complex.
Is there a method to use the STRAGG  function without the group by clause.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial