Anda membutuhkan kueri seperti ini. Pastikan Anda menyertakan NULL
memeriksa Data1, Data2 ketika catatan hilang untuk tanggal mendatang atau tanggal yang lalu dan default ke nol jika perlu.
select To_CHAR(Month,'MON-YY') Month,
CASE
WHEN MOD ( EXTRACT ( MONTH FROM Month ), 3 ) = 1
THEN Data2 + LEAD ( Data2 ,1) OVER ( ORDER BY Month ) + LEAD ( Data2 ,2) OVER ( ORDER BY Month )
WHEN MOD ( EXTRACT ( MONTH FROM Month ), 3 ) = 2
THEN LAG(Data1,1) OVER ( ORDER By Month ) + Data2 + LEAD ( Data2 ,1) OVER ( ORDER BY Month )
WHEN MOD ( EXTRACT ( MONTH FROM Month ), 3 ) = 0
THEN LAG(Data1,2) OVER ( ORDER By Month ) + LAG(Data1,1) OVER ( ORDER By Month )+Data2
END data
FROM
Table1;