SELECT * FROM (
SELECT --SUBSTR(DATES, 1, 7) timest ,
nvl(nvl(ORGID,'s'),'x'),
SUM(A.PAIDINAMT) PAIDINAMT,
SUM(SUM(A.PAIDINAMT) ) OVER(ORDER BY sum(A.PAIDINAMT) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) TOTAL_PAIDINAMT --,
--SUM(SUM(A.PAIDINAMT) ) OVER(ORDER BY SUBSTR(DATES, 1, 7) ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) TOTAL_PAIDINAMT1
FROM C##_SHOP.RETBILLMT A
WHERE 1 = 1
AND SUBSTR(DATES, 1, 7) = '2016-08'
GROUP BY rollup(nvl(ORGID,'s'))
--GROUP BY ORGID ,SUBSTR(DATES, 1, 7)
)