Do you mean: ``` select last_date, count(distinct id) from ( select id, max(date_status_added) as last_date from reg_history_all where not id in ( select id from reg_history_all where reg_status = 'Deceased' ) and date_status_added < 43000 group by id having reg_status = 'Registered' ) group by last_date ; ```