Please refer to this question if needed as this is a continuation of that:
for vColKey in
select colkey, sum(colcount) colcount from
,case when lead(colstartdt) over (partition by colkey order by colstartdt) > colenddt
group by colkey
order by colkey
select min(ColStartDt) into vMinColStartDt
from tblMyTable where ColKey=vColKey;
for vColPk in
order by ColKey, ColStartDt
set ColStartDt=vMinColStartDt + cur_rownum-1 * 3,
For the first row, ColStartDt will be vMinColStartDt as cur_rownum will be 1. For the next row, ColStartDt will be exactly 3 days greater than previous row's ColStartDt. IMPORTANT: the updates should happen in increasing ColStartDt order.
I don't want to write an UPDATE statement for every line.
What would be the right SQL for this?