From 05a96a3a29861e682f01498c5499eb686d064409 Mon Sep 17 00:00:00 2001 From: will king Date: Wed, 7 Jun 2023 13:03:21 -0700 Subject: [PATCH] adding scripts --- Scripts/ExtractingData.sql | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Scripts/ExtractingData.sql b/Scripts/ExtractingData.sql index 0648013..880ef03 100644 --- a/Scripts/ExtractingData.sql +++ b/Scripts/ExtractingData.sql @@ -633,4 +633,26 @@ select count(distinct nct_id) from formatted_data_with_planned_enrollment;--48 +select count(distinct nct_id) from public.view_trial_to_cause; --130 +select count(distinct nct_id) from formatted_data_with_planned_enrollment;--48 + +--get durations and count snapshots per trial per trial +with cte1 as ( +select + nct_id, + start_date , + primary_completion_date, + overall_status , + primary_completion_date - start_date as duration +from ctgov.studies s +where nct_id in (select distinct nct_id from http.download_status ds) +), cte2 as ( +select nct_id,count(*) as snapshot_count from formatted_data_with_planned_enrollment fdwpe +group by nct_id +) +select a.nct_id, a.overall_status, a.duration,b.snapshot_count +from cte1 as a + join cte2 as b + on a.nct_id=b.nct_id +;