how can get like this result
table A
col1 col2
--- -----

a A
b B
C C
.. ..
.. ...
.. ...
wants result like for a single column

col1
------
a,b,c,........n of data


and


another is


col1
-------
A B C D ........
a b b d ........

Answers were Sorted based on User's Feedback



how can get like this result table A col1 col2 --- ----- a A b B C C .. .. .. ... ..

Answer / ajit

select wm_concat(col1) col1
from t1;

select wm_concat(col2)||chr(10)||
wm_concat(col1) col1
from t1;

Is This Answer Correct ?    1 Yes 0 No

how can get like this result table A col1 col2 --- ----- a A b B C C .. .. .. ... ..

Answer / suman rana

If you are using Oracle 11g Release 1 and above version,
following queries will work.

SELECT listagg (b, ',') WITHIN GROUP (ORDER BY 1) hh
FROM (SELECT 'A' a, 'a' b FROM DUAL
UNION
SELECT 'B', 'b' FROM DUAL
UNION
SELECT 'C', 'c' FROM DUAL);


WITH qry AS
(SELECT 'A' a, 'a' b FROM DUAL
UNION
SELECT 'B', 'b' FROM DUAL
UNION
SELECT 'C', 'c' FROM DUAL)
SELECT listagg (a, ' ') WITHIN GROUP (ORDER BY 1) FROM qry
UNION ALL
SELECT listagg (b, ' ') WITHIN GROUP (ORDER BY 1) FROM qry;

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More Oracle General Interview Questions

What are the values that can be specified for OPTIMIZER MODE Parameter ?

1 Answers  


Please HELP me its urgent? If i want to EXPORT data from SQL server to ORACLE 11g then how can I replicate data from SQL to ORACLE?

3 Answers  


What is a trace file and how is it created in oracle?

1 Answers  


How many objectname will be created for a single table drop function? Why 'flashback' query giving error "ORA-38312: original name is used by an existing object" while getting the table?

1 Answers  


what is the use of triggers in Java program? I mean where do we use triggers in Java programming?

1 Answers  


What is pragma restrict_reference in oracle 9i?When we use this?Give me one realtime scenario?

4 Answers   Microsoft, Wipro,


I just want to maintain data like an employee can belongs to 3 or more departments . We can resolve this by using composite key but it avoids normalization rules. So Can anyone tell me how can I maintain data.

1 Answers   IBM,


What is archive log in Oracle?

1 Answers   MCN Solutions,


what is unique key?

14 Answers   Amazon, Cap Gemini, Infosys, Wipro,


Please explan Why static query is more faster than dynamic query ?

2 Answers  


diff between DELETE and TRUNCATE?.

14 Answers   HCL, Yalamanchili Software,


what is the syntax of INSERT command?

7 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1803)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)