Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

i have a table in which the values are

id      value
----------------
1         10
1         20
1         30
2         33
2         34

I want the output given below using sql:

id          value
-------------------
1             10
              20
              30
--------------------
2             33
              34
-------------------- 
share|improve this question
add comment

1 Answer

Query:

SELECT id, ListAgg(to_char(value), chr(10) || chr(13)) WITHIN GROUP (ORDER BY value) "Values" 
FROM t1 GROUP BY id;

Output:

ID Values   
-- ----------
 1 10         
   20          
   30          

 2 33         
   34          

Setup:

DROP TABLE T1;
CREATE TABLE t1 AS (SELECT 1 id, level * 10 value FROM dual CONNECT BY level <=3);
INSERT INTO t1 VALUES (2,33);
INSERT INTO t1 VALUES (2,34);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.