set startlife = r_startlife
with recursive demo( rno, r_probsurv, r_startlife) as
(select 0, 1::numeric, 100000::numeric -- prime the recursion
select id,probsurv, r_probsurv*r_startlife
on (id = (select min(id) -- since I do trust autogenerated ids
from life_expectancy -- to actually be in perfect sequence
where id > rno))
select rno,r_probsurv, round(r_startlife) r_startlife
where id = rno; The above query is working for one single phr_makkal_district. But I need to execute this query for all phr_makkal_district.
Need to apply condition in this query. Once reach the age_range 0-1 Year need to update 100000(defaut value) in the startlife columns for the next phr_makkal_district.