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

What is prepared statement in sql?

561


Can one improve the performance of sql*loader? : aql loader

595


What is a full join sql?

604


what is clause? : Sql dba

607


How to create an array in pl/sql?

590






Is time a data type in sql?

488


What do you mean by dbms? What are its different types?

560


What program will open a mdb file?

509


What is user in sql?

595


How many clustered indexes can be created on a table?

601


How bulk collect improves performance?

578


What is inner join in sql?

594


What is multiple columns?

584


What are triggers in sql?

591


how to increment dates by 1 in mysql? : Sql dba

549