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 are variables in pl sql?

561


what is acid property in database? : Sql dba

559


how to analyze tables with 'mysqlcheck'? : Sql dba

542


what is unique key constraint? : Sql dba

564


How do you explain an index number?

531






How to use sql*plus built-in timers?

576


How many types of primary keys are there?

525


What is meaning of <> in sql?

583


how to create a test table in your mysql server? : Sql dba

494


Explain the the delete statements in sql?

575


Is sql an operating system?

543


Is oracle and sql same?

569


How to display Row Number with Records in Oracle SQL Plus?

590


What is sql and its types?

625


What is blind sql injection?

572