DELETE FROM http.download_status;

INSERT INTO http.download_status (nct_id, status)
SELECT nct_id, 'Of Interest'::http.history_download_status AS status
FROM ctgov.studies
WHERE 
    is_fda_regulated_drug=TRUE
    AND
    study_type = 'Interventional'
    AND
    phase='Phase 3'
    AND 
    overall_status in ('Terminated', 'Completed')
    AND 
    start_date > '2010-01-01'
    AND
    completion_date < '2022-01-01'
;


SELECT count(*) FROM http.download_status ;
