Link to home
Start Free TrialLog in
Avatar of tonMachine100
tonMachine100

asked on

Pivot data from multiple rows onto one field - oracle 10 sql syntax

Please see the attached which displays fig1 sample data and fig2. desired output.

I want to concatenate data from multiple rows in one column into one field and join them with the word 'and'.

Any help with the syntax would be appreciated
sample.xls
Avatar of wietman
wietman
Flag of United States of America image

So in this case, you are not grouping the data in any way.  You want a particular column of every single row pivoted.  Am I restating this correctly?
Avatar of tonMachine100
tonMachine100

ASKER

yes thats correct
Usually , there is some kind of grouping in a pivot and we would also need to explicitly group by known fields.  You example does not fit here.  It seems to me this really requires a much more simple example.

What about simply:

select per_name||' and '  from table_name

This would, of course leave an extra 'and' at the end but if I'm on the right track, I think I could fix that.
It also puts a CR after each 'and'.  There are ways around that , too.  Just let me know what is or is not acceptable with this solution.  I can solve both of these issues with an anonymous pl/sql block.  just let me know how you would like me to proceed.
ASKER CERTIFIED SOLUTION
Avatar of POracle
POracle
Flag of India 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
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