SELECT why_stopped FROM ctgov.studies
WHERE why_stopped IS NOT NULL
LIMIT 100;

SELECT study_type, count(*) from ctgov.studies
group by study_type;

SELECT is_fda_regulated_drug, count(*) from ctgov.studies
GROUP BY is_fda_regulated_drug;



/*
Note that there is a decent number of trials that have expanded access
*/
SELECT 
	study_type
	, phase
	, has_expanded_access
	, has_dmc
	, count(*) 
FROM ctgov.studies
WHERE 
	is_fda_regulated_drug is true
	AND
	study_type = 'Interventional'
	AND 
	start_date > date('2007-01-01')
group by study_type, phase, has_expanded_access, has_dmc;




/*
 Find different mesh terms as assigned by clinicaltrials.gov
 */
select * from ctgov.browse_conditions
order by nct_id desc,mesh_type
limit 200;

select * from ctgov.browse_interventions
order by nct_id desc
limit 200;

