I have written a sql but there is a slight prob with it.
What i have is:
WITH parent (col1,path) AS
(SELECT DISTINCT
col1
,cast(col2 as char)
FROM my_table
WHERE col1 = 1
UNION ALL
SELECT C.col1
,cast(P.col2 as char) || '-' || cast(C.col2 as char)
FROM my_table C
,parent P
WHERE P.col1 = C.col1-1
)
SELECT *
FROM parent;
result I am getting is:
1,a
2,a-b
3,b-c
4,c-d
5,d-e
6,e-f
But what I am expecting is:
1,a
2,a-b
3,a-b-c
4,a-b-c-d
5,a-b-c-d-e
6,a-b-c-d-e-f