SQL using partition and connect by clause.

select id, max(ltrim(sys_connect_by_path(gred,' , '),' , ')) as mygred
from (select b.KJ19SIJIL||b.KJ19KOD as id, b.KJ19GRED as gred, row_number() over(partition by b.KJ19SIJIL||b.KJ19KOD order by b.KJ19GRED) as myrow
from kj19setara b)
start with myrow = 1
connect by prior myrow = myrow -1
and prior id = id
group by id
order by 1;

Comments

Unknown said…
mender nie tak paham....sila jelaskan laa....

Popular Posts