Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 use of package in pl sql?

1018


what is a join? : Sql dba

1041


how many columns can be used for creating index? : Sql dba

948


What is compute?

1098


What if we write return in procedure?

1432


how can we optimize or increase the speed of a mysql select query? : Sql dba

951


Can we use view in stored procedure?

904


Explain the savepoint statement.

1102


what is a database lock ? : Sql dba

1176


how to install mysql? : Sql dba

1113


what is blob? : Sql dba

1155


what is an index? : Sql dba

1003


What is difference between left and right outer join?

993


How does an execution block start and end in pl sql?

957


what are the security recommendations while using mysql? : Sql dba

1124