?
Solved

Repeat Group Columns

Posted on 2010-11-16
8
Medium Priority
?
582 Views
Last Modified: 2012-05-10
My request is straight forward, I wan to turn multiple rows into one row with multiple columns in oracle sql.
0
Comment
Question by:Roberto Madro R.
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 14

Expert Comment

by:ajexpert
ID: 34149965
Can you show us the sample output?
0
 

Author Comment

by:Roberto Madro R.
ID: 34150052
Sorry, I have no ouput, and no script generated yet, I'd like to see how you'd approach such request, here's the basics;

That's what I get now.

Unit, Test Type, Test Results

AA, AGN1, 11
AA, XZf2, 13.5
AA, ADGv, 17

I don't care for the "Test Type, I just want the "Unit" and "Test Results" to come out as follows;

AA, 11, 13.5, 17, ..
0
 
LVL 3

Expert Comment

by:mpaladugu
ID: 34150292
select column_name||column_name2||column_name3 column_alias from table name
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:mpaladugu
ID: 34150315
sorry that is wrong..ignore the above comment
0
 
LVL 3

Expert Comment

by:mpaladugu
ID: 34150458
http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

above link has a direct answer to your question
0
 
LVL 3

Accepted Solution

by:
mpaladugu earned 2000 total points
ID: 34150632
If you are using 10g, then this should do the trick without using pl/sql function,

copied from the link posted above...
Base Data:

    DEPTNO ENAME
---------- ----------
        20 SMITH
        30 ALLEN
        30 WARD
        20 JONES
        30 MARTIN
        30 BLAKE
        10 CLARK
        20 SCOTT
        10 KING
        30 TURNER
        20 ADAMS
        30 JAMES
        20 FORD
        10 MILLER

SELECT deptno,
       LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
       KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM   (SELECT deptno,
               ename,
               ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
               ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
        FROM   emp)
GROUP BY deptno
CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
START WITH curr = 1;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 ADAMS,FORD,JONES,SCOTT,SMITH
        30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
0
 

Author Comment

by:Roberto Madro R.
ID: 34250851
I thought I closed this string not due to any specific solution but rather to the deep insights provided by couple of members on this forum, I'm appreciative and thankful for their input, programmers in every field don't necessarily copy other people's ideas but other people's ideas usually inspire them to code differently thus getting the result they want. That's what happened in this case.

Many Thanks
0
 

Author Closing Comment

by:Roberto Madro R.
ID: 34250855
.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question