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
Solved

Repeat Group Columns

Posted on 2010-11-16
8
579 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.
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

861 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