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
Answer / bubun4u
select cust, REPLACE(wm_conact(acc), ',', '|') as acc from table
group by cust
| Is This Answer Correct ? | 8 Yes | 1 No |
Answer / phanikumar
select cust,listagg(acc,'|') within group(order by acc) from
tbl group by cust;
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / kpk
select cust,wmsys.wm_concat(acc) from tbl group by cust;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / rajgopal
select cust,wm_concate(acc) from table_name group by cust;
| Is This Answer Correct ? | 1 Yes | 1 No |
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 |
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 |
Answer / trainedforjob
select cust, wm_conact(acc) as acc from table
group by cust
| Is This Answer Correct ? | 1 Yes | 3 No |
how to analyze tables with 'mysqlcheck'? : Sql dba
What operating systems are supported by oracle sql developer?
What are all the difference between Like and Contains ?
what is a constraint? Tell me about its various levels. : Sql dba
if table named a is there and 4 records are there then how to swap (1 and 3) and (2 and 4) records at a time
What is character functions?
What is sql lookup?
what is sql? : Sql dba
What is sql entity?
what is cursor procedure
write an sql query to find names of employee start with 'a'? : Sql dba
What are the types of variables use in pl sql?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)