469,126 Members | 1,295 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,126 developers. It's quick & easy.

Query

I have data in the table as following :
10 AGR
10 ECO
10 GOP
11 RBL
11 RBS

where first field is id and second is code , Now , I want to display data as follows :

10 AGR,ECO,GOP
11 RBL,RBS

i want accomplish this using a query
Jul 11 '07 #1
1 840
debasisdas
8,127 Expert 4TB
You can try this sample code for your solution
====================================
Expand|Select|Wrap|Line Numbers
  1. select empno,ename,
  2. max(decode(rn, 1, job))||'/' col1,
  3. max(decode(rn, 2, job)) col2
  4. from (
  5. select empno,ename,job, row_number() over (partition by empno order by empno) rn
  6. from emp
  7. order by empno)
  8. group by empno,ename
But still i recommend to use cursor for the purpose.
Jul 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by jaysonsch | last post: by
9 posts views Thread by netpurpose | last post: by
3 posts views Thread by Harvey | last post: by
4 posts views Thread by Diamondback | last post: by
14 posts views Thread by Dave Thomas | last post: by
4 posts views Thread by Stan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.