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

I Want below o/p:
cust acc
-----------
a 1
b 2
b 3
c 4
c 5
c 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|3 c 4|5|6..

Answer / kavitha nedigunta

create table test001 (cuss varchar2(10), acc varchar2(30));

insert into test001 values ('a','1');

insert into test001 values ('b','2|3');

insert into test001 values ('c','4|5|6');

WITH CTE AS (SELECT CUSS,ACC FROM TEST001)
select distinct trim(regexp_substr( acc, '[^|]+', 1,
level)) acc ,cuss from cte
CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(ACC, '[^|]+')) +
1;

Is This Answer Correct ?    3 Yes 3 No

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

Answer / p deshmukh

SELECT distinct COL, trim(regexp_substr(colvalue, '[^|]+', 1, level)) colvalue
FROM (with demo as ( select '1' as a, '2|3' as b, '4|5|6' as c from dual )

select * from demo
unpivot
( colvalue for col in (a, b, c) )) t
CONNECT BY instr(colvalue, '|', 1, level - 1) > 0
order by col

Is This Answer Correct ?    0 Yes 0 No

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

Answer / punith

SELECT a,
REGEXP_SUBSTR (b, '([^|]+)', 1, lvl) b


FROM dummy,
(SELECT LEVEL lvl
FROM (SELECT MAX (LENGTH (REGEXP_REPLACE
(b, '[^|]'))) mx
FROM dummy)
CONNECT BY LEVEL <= mx + 1)
WHERE lvl - 1 <= LENGTH (REGEXP_REPLACE (b, '[^|]'));

Is This Answer Correct ?    0 Yes 2 No

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

Answer / monu singh shekhawat

select * from tab
group by acc

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More SQL PLSQL Interview Questions

How long it takes to learn pl sql?

0 Answers  


one of the column in my table contains the data like SAL ---- 1000 1000 2000 3000 3000 So my requirement is i want output like SAL --- 1000 2000 3000 it mean i want to delete duplicate rows in the table permanently and i want output in the above formatow should u write query?

13 Answers   Cap Gemini, TCS,


Why do we use cursors?

0 Answers  


How do I find duplicates in the same column?

0 Answers  


How will you select unique values from a list of records?

7 Answers   Cap Gemini,






What are the uses of merge?

0 Answers  


Why stored procedures are faster than query?

0 Answers  


What are the different types of dbms?

0 Answers  


What is a trigger word?

0 Answers  


how to insert the records in particular position

1 Answers  


What is pl sql package?

0 Answers  


Explain what is a subquery ?

0 Answers  


Categories