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.

Answers were Sorted based on User's Feedback



I have a tablle like this: cust acc ----------- a 1 b 2 b 3 c 4 c ..

Answer / bubun4u

select cust, REPLACE(wm_conact(acc), ',', '|') as acc from table
group by cust

Is This Answer Correct ?    8 Yes 1 No

I have a tablle like this: cust acc ----------- a 1 b 2 b 3 c 4 c ..

Answer / phanikumar

select cust,listagg(acc,'|') within group(order by acc) from
tbl group by cust;

Is This Answer Correct ?    6 Yes 0 No

I have a tablle like this: cust acc ----------- a 1 b 2 b 3 c 4 c ..

Answer / kpk

select cust,wmsys.wm_concat(acc) from tbl group by cust;

Is This Answer Correct ?    0 Yes 0 No

I have a tablle like this: cust acc ----------- a 1 b 2 b 3 c 4 c ..

Answer / rajgopal

select cust,wm_concate(acc) from table_name group by cust;

Is This Answer Correct ?    1 Yes 1 No

I have a tablle like this: cust acc ----------- a 1 b 2 b 3 c 4 c ..

Answer / dinesh

select cust, listagg(acc,'|') WITHIN GROUP (ORDER BY ACC )as ACC from cust1 group by cust;




This LISTAGG Function is the concept of 11g release2. and
this is the best answer for this question.

Is This Answer Correct ?    0 Yes 0 No

I have a tablle like this: cust acc ----------- a 1 b 2 b 3 c 4 c ..

Answer / 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

I have a tablle like this: cust acc ----------- a 1 b 2 b 3 c 4 c ..

Answer / trainedforjob

select cust, wm_conact(acc) as acc from table
group by cust

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More SQL PLSQL Interview Questions

What is a sql driver?

0 Answers  


What is a column in a table?

0 Answers  


Can we write dml inside a function in sql server?

0 Answers  


What is scalar function in sql?

0 Answers  


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

0 Answers  


how are rank and dense rank being alloted for column with same values over a particular column

1 Answers  


what is the forward decleration in packages?

1 Answers  


What are transaction and its controls?

0 Answers  


When would you denormalize?

8 Answers   MBT, Microsoft, MMU,


Temporary table vs Table variable in sql server?

0 Answers   Wipro,


Give an example of Full Outer Join?

1 Answers   IBM,


What is dcl in sql?

0 Answers  


Categories