adspace


I have a tablle like this:

cust acc
-----------
a 1
b 2
b 3
c 4
c 5
c 6


I Want below o/p:
cust acc
---------------
a 1
b 2|3
c 4|5|6

Please any one can you have any ideas share me.
I have urgent requirement.

Answer Posted / prathibha

select customer_id,

MAX(CASE WHEN RNK MOD 8 = 1 THEN ACCOUNT_NO ELSE '' END) ||
MAX(CASE WHEN RNK MOD 8 = 2 THEN ',' || ACCOUNT_NO ELSE '' END) ||
MAX(CASE WHEN RNK MOD 8 = 3 THEN ',' || ACCOUNT_NO ELSE '' END)
AS ACCOUNT_NO
FROM
(
select customer_id,account_no, rank() over (partition by customer_id order by account_no) as rnk
from customer_account ) TEMP
GROUP BY 1


The above query is tested and it works.

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Hi am new to PLSQL & facing problems in writing code like in SP, Functions, so any one having some SP coding with in depth explanation please share with me my Email ID suvarnaatsuvarna@rediffmail.com Or taking tanning on this please do contact me

2090


Can we rollback truncate?

1074


Can delete statement be rollbacked?

1054


what is schema? : Sql dba

1146


how to start mysql server? : Sql dba

1266


what is bcp? When does it used? : Sql dba

1055


Can we use distinct and group by together?

1133


Does group by remove duplicates?

1112


what is collation? : Sql dba

1229


define sql insert statement ? : Sql dba

1098


what are the advantages of sql ? : Sql dba

1142


If a cursor is open, how can we find in a pl/sql block?

1238


what are aggregate and scalar functions? : Sql dba

1129


How do I remove duplicates in two columns?

1186


what are all the common sql function? : Sql dba

1131