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
What is use of package in pl sql?
what is a join? : Sql dba
how many columns can be used for creating index? : Sql dba
What is compute?
What if we write return in procedure?
how can we optimize or increase the speed of a mysql select query? : Sql dba
Can we use view in stored procedure?
Explain the savepoint statement.
what is a database lock ? : Sql dba
how to install mysql? : Sql dba
what is blob? : Sql dba
what is an index? : Sql dba
What is difference between left and right outer join?
How does an execution block start and end in pl sql?
what are the security recommendations while using mysql? : Sql dba