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

How would you change old and new values in an insert, delete and update triggers?

0 Answers  


Table1- have two column filename data AFGDFD-20112011 hi how r u bsdasd-23042011 name shoud be in bold Now i want output like filename data AFGDFD hi how r u bsdasd name shoud be in bold Kindly answer this

2 Answers   HCL,


What is ordinary table in oracle?

0 Answers   MCN Solutions,


What is the use of oracle?

0 Answers  


What is a data segment ?

1 Answers  






What is a procedure in oracle?

0 Answers  


What are the limitations oracle database 10g xe?

0 Answers  


Using the relations and the rules set out in the notes under each relation, write statements to create the two sequence generators specified in the notes.

0 Answers   Wipro,


What is the meaning of recursive hints in oracle?

0 Answers  


What is Trace File ?

4 Answers   Thermotech,


How can we view last record added to a table?

0 Answers  


What is analyze command used for?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • 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)