also http://asktom.oracle.com/ and search for stragg
Main Topics
Browse All Topicshi,
I have 4 columns which is show below
COL1 COL2 COL3 COL4
1 ABC 10 JAN
FEB
MAR
MY REQUIREMENT IS
COL1 COL2 COL3 COL4
1 ABC 10 JAN,FEB,MAR
Can I get this in SQL
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
also http://asktom.oracle.com/ and search for stragg
right I do this against the scot.emp table as follows:
SQL> column empl format a80
SQL> CREATE OR REPLACE FUNCTION my_emp_list(m_deptno IN NUMBER) RETURN VARCHAR2 AS
2 m_str VARCHAR2(100) := '';
3 BEGIN
4 FOR emp_cur IN (SELECT ename FROM emp WHERE deptno = m_deptno) LOOP
5 IF m_str IS NOT NULL THEN
6 m_str := m_str || ',';
7 END IF;
8 m_str := m_str || emp_cur.ename;
9 END LOOP;
10 RETURN m_str;
11 END;
12 /
Function created.
SQL> SELECT deptno, my_emp_list(deptno) empl
2 FROM emp
3 GROUP BY deptno
4 /
DEPTNO EMPL
---------- --------------------------
10 CLARK,KING,MILLER
20 SMITH,JONES,SCOTT,ADAMS,FO
30 ALLEN,WARD,MARTIN,BLAKE,TU
SQL>
Hope you enjoy this query:)
If your data is as follows
and you have only values JAN...DEC for col4, then you can use a query like this for getting what you want.
select id, trim(',' from
max(decode(month,'JAN',mon
max(decode(month,'FEB',mon
max(decode(month,'MAR',mon
max(decode(month,'APR',mon
max(decode(month,'MAY',mon
max(decode(month,'JUN',mon
max(decode(month,'JUL',mon
max(decode(month,'AUG',mon
max(decode(month,'SEP',mon
max(decode(month,'OCT',mon
max(decode(month,'NOV',mon
max(decode(month,'DEC',mon
from c
group by id, name, id2
/
It will return results like:
SQL> select * from c;
ID NAME ID2 MONTH
---------- --------------------------
1 ABC 10 JAN
1 ABC 10 FEB
1 ABC 10 MAR
2 XYZ 10 MAY
2 XYZ 10 DEC
SQL> select id, trim(',' from
2 max(decode(month,'JAN',mon
3 max(decode(month,'FEB',mon
4 max(decode(month,'MAR',mon
5 max(decode(month,'APR',mon
6 max(decode(month,'MAY',mon
7 max(decode(month,'JUN',mon
8 max(decode(month,'JUL',mon
9 max(decode(month,'AUG',mon
10 max(decode(month,'SEP',mon
11 max(decode(month,'OCT',mon
12 max(decode(month,'NOV',mon
13 max(decode(month,'DEC',mon
14 from c
15 group by id, name, id2
16 /
ID MONTHS
---------- --------------------------
1 JAN,FEB,MAR
2 MAY,DEC
Business Accounts
Answer for Membership
by: angelIIIPosted on 2006-10-31 at 10:40:29ID: 17844301
http://www.oracle-base.com /articles/ 10g/ String Aggregatio nTechnique s.php m/t/3588/0 /
http://www.orafaq.com/foru