From c02b399867140e661f553487eca8992fe4f36fc5 Mon Sep 17 00:00:00 2001 From: "goalkeep@dosteducation.com" Date: Wed, 22 Nov 2023 06:55:58 +0000 Subject: [PATCH 1/3] add state and district wise signup subquery --- .../slg/int_registration_metrics.sql | 47 +++++++++++++++++-- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/models/intermediate/slg/int_registration_metrics.sql b/models/intermediate/slg/int_registration_metrics.sql index 52eb195..c51a99e 100644 --- a/models/intermediate/slg/int_registration_metrics.sql +++ b/models/intermediate/slg/int_registration_metrics.sql @@ -156,7 +156,26 @@ with cast(user_registered_on as date) as date, count(distinct user_phone) as signups from select_latest_record - where user_signed_up_to_uk_program_on is not null and user_registered_on >= '2021-06-01' and sector_name is null + where user_signed_up_to_uk_program_on is not null and user_registered_on >= '2021-06-01' and sector_name is null and (block_name != 'N/A' or block_name is not null) + group by 1,2 + ), + calculate_signups_districtwise as ( + select + state_name, + district_name, + cast(user_registered_on as date) as date, + count(distinct user_phone) as signups + from select_latest_record + where user_signed_up_to_uk_program_on is not null and user_registered_on >= '2021-06-01' and sector_name is null and (block_name = 'N/A' or block_name is null) and district_name is not null + group by 1,2,3 + ), + calculate_signups_statewise as ( + select + state_name, + cast(user_registered_on as date) as date, + count(distinct user_phone) as signups + from select_latest_record + where user_signed_up_to_uk_program_on is not null and user_registered_on >= '2021-06-01' and sector_name is null and (block_name = 'N/A' or block_name is null) and district_name is null group by 1,2 ), join_signups_sectorwise as ( @@ -173,14 +192,32 @@ with left join calculate_signups_blockwise using (date,block_name) where activity_level = 'Block' ), - append_signups as ( + join_signups_districtwise as ( + select + * + from date_geographies + left join calculate_signups_districtwise using (date,district_name, state_name) + where activity_level = 'District' + ), + join_signups_statewise as ( select - * + * + from date_geographies + left join calculate_signups_statewise using (date,state_name) + where activity_level = 'State' + ), + append_signups as ( + select * from join_signups_sectorwise union all - select - * + select * from join_signups_blockwise + union all + select * + from join_signups_districtwise + union all + select * + from join_signups_statewise ), add_signups_to_cross_join_table as ( select From 26b4b7ac651c9ad1407fe040507d5f3aefaf05da Mon Sep 17 00:00:00 2001 From: "goalkeep@dosteducation.com" Date: Thu, 30 Nov 2023 06:37:52 +0000 Subject: [PATCH 2/3] moved int_dates file to intermediate slg folder --- models/intermediate/{ => slg}/int_dates.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename models/intermediate/{ => slg}/int_dates.sql (100%) diff --git a/models/intermediate/int_dates.sql b/models/intermediate/slg/int_dates.sql similarity index 100% rename from models/intermediate/int_dates.sql rename to models/intermediate/slg/int_dates.sql From c475dc9ef540c341bd25294988c8ff07fc20fc0a Mon Sep 17 00:00:00 2001 From: "goalkeep@dosteducation.com" Date: Thu, 30 Nov 2023 06:39:09 +0000 Subject: [PATCH 3/3] moved again outside the SLG folder --- models/intermediate/{slg => }/int_dates.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename models/intermediate/{slg => }/int_dates.sql (100%) diff --git a/models/intermediate/slg/int_dates.sql b/models/intermediate/int_dates.sql similarity index 100% rename from models/intermediate/slg/int_dates.sql rename to models/intermediate/int_dates.sql