SQLite Forum

How to convert to CTE
Login
Have this SQL, which counts the number of registered patients at a given date. These are integer Excel dates, so where 1/1/1900 is 0:

select count(*) as Cnt 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')

Now I would like to do this for all dates
between say 1000 and 43000, getting in the output all these dates and counts.

RBS