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 are the various restrictions imposed on view in terms of dml?
what are local and global variables and their differences? : Sql dba
When is the explicit cursor used ?
Can a foreign key be null?
What are the built in functions of sql?
How to use boolean type in select statement?
What are the advantages of stored procedure?
How do I run pl sql in sql developer?
What is #table in sql?
Can we rollback truncate?
What are the different schemas objects that can be created using pl/sql?
What is a record in a database?
What is auto increment in sql?
How many sql are there?
Can a foreign key have a different name?