clear markdown help donate comments/suggestions/bugs a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith?
By using dbfiddle, you agree to license everything you submit by Creative Commons CC0

CREATE TABLE tab(NR NVARCHAR2(100), GRD NVARCHAR2(100), DT DATE);

INSERT INTO tab SELECT '00000000000000000001' AS NR, N'06' AS GRD, DATE '2013-01-01' AS DT FROM dual UNION ALL SELECT '00000000000000000001' ,N'06', DATE '2013-01-01' FROM dual UNION ALL SELECT '00000000000000000001' ,N'21', DATE '2013-01-01' FROM dual UNION ALL SELECT '00000000000000000002' ,N'06', DATE '2013-01-01' FROM dual UNION ALL SELECT '00000000000000000002' ,N'21', DATE '2013-01-01' FROM dual UNION ALL SELECT '00000000000000000004' ,N'01', DATE '2013-03-31' FROM dual;
6 rows affected

CREATE TYPE tbl_array AS TABLE OF NVARCHAR2(4000);

select nr , CAST(collect(grd) AS tbl_array) grds from tab group by nr
NR GRDS

with prep as ( select nr , CAST(collect(grd) AS tbl_array) grds, ROW_NUMBER() OVER(ORDER BY nr) AS rn from tab group by nr ) select p.NR, p.grds, p2.grds as lead_grds from prep p LEFT JOIN prep p2 ON p2.rn = p.rn +1;
NR GRDS LEAD_GRDS