From 15fa09aeac059bd506eff20b69539333817ccc3e Mon Sep 17 00:00:00 2001 From: Ruslan Date: Mon, 7 Oct 2024 14:32:34 +0300 Subject: [PATCH] +subpoena, temporary_measure --- .../main_dashboard.recruitment_campaign.ktr | 44 +- .../main_dashboard.total_registered.ktr | 62 +- .../main_dashboard.waiting_registration.ktr | 64 +- .../total_registered.driver_license.ktr | 118 +- .../total_registered.removed_registry.ktr | 271 +-- mappings/info_recruits/job_info_recruits.kjb | 294 ++- mappings/info_recruits/subpoena.ktr | 691 ++++++ mappings/info_recruits/temporary_measure.ktr | 674 ++++++ .../main_dashboard.total_registered(reg).ktr | 122 +- ...in_dashboard.waiting_registration(reg).ktr | 134 +- mappings/region/total_registered.age(reg).ktr | 1992 ++++++++--------- 11 files changed, 3029 insertions(+), 1437 deletions(-) create mode 100644 mappings/info_recruits/subpoena.ktr create mode 100644 mappings/info_recruits/temporary_measure.ktr diff --git a/mappings/country/main_dashboard.recruitment_campaign.ktr b/mappings/country/main_dashboard.recruitment_campaign.ktr index fc9fbfa..6ce1380 100644 --- a/mappings/country/main_dashboard.recruitment_campaign.ktr +++ b/mappings/country/main_dashboard.recruitment_campaign.ktr @@ -799,8 +799,8 @@ rdi.applied_date AS ap_date, rdi.id AS rdi_id, ssi.delivery_code AS d_code, - s.recruit_id, -- Добавляем recruit_id, если оно существует в таблице s (subpoena) - ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY sh.date_time DESC) AS rn + s.recruit_id, -- recruit_id добавляем, если есть + sh.date_time FROM public.subpoena s JOIN public.subpoena_history AS sh ON sh.subpoena_id = s.id JOIN public.subpoena_status AS ss ON ss.id = s.status_id @@ -812,10 +812,22 @@ WHERE sr.type = '1' AND EXTRACT(YEAR FROM AGE(s.date_birth)) BETWEEN 18 AND 30 ), +last_status_data AS ( + -- Выбираем последнюю дату истории для каждой subpoena + SELECT + s.subpoena_id, + MAX(s.history_date) AS last_history_date + FROM subpoena_data s + GROUP BY s.subpoena_id +), last_status AS ( - SELECT * - FROM subpoena_data - WHERE rn = 1 + -- Соединяем таблицу с максимальной датой и оригинальные данные, чтобы выбрать последние записи + SELECT + sd.* + FROM subpoena_data sd + JOIN last_status_data lsd + ON sd.subpoena_id = lsd.subpoena_id + AND sd.history_date = lsd.last_history_date ), t1 AS ( SELECT COUNT(DISTINCT subpoena_id) AS count_subpoena @@ -897,8 +909,8 @@ JOIN t4 ON true; rdi.applied_date AS ap_date, rdi.id AS rdi_id, ssi.delivery_code AS d_code, - s.recruit_id, -- Добавляем recruit_id, если оно существует в таблице s (subpoena) - ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY sh.date_time DESC) AS rn + s.recruit_id, -- recruit_id добавляем, если есть + sh.date_time FROM public.subpoena s JOIN public.subpoena_history AS sh ON sh.subpoena_id = s.id JOIN public.subpoena_status AS ss ON ss.id = s.status_id @@ -910,10 +922,22 @@ JOIN t4 ON true; WHERE sr.type = '1' AND EXTRACT(YEAR FROM AGE(s.date_birth)) BETWEEN 18 AND 30 ), +last_status_data AS ( + -- Выбираем последнюю дату истории для каждой subpoena + SELECT + s.subpoena_id, + MAX(s.history_date) AS last_history_date + FROM subpoena_data s + GROUP BY s.subpoena_id +), last_status AS ( - SELECT * - FROM subpoena_data - WHERE rn = 1 + -- Соединяем таблицу с максимальной датой и оригинальные данные, чтобы выбрать последние записи + SELECT + sd.* + FROM subpoena_data sd + JOIN last_status_data lsd + ON sd.subpoena_id = lsd.subpoena_id + AND sd.history_date = lsd.last_history_date ), t1 AS ( SELECT COUNT(DISTINCT subpoena_id) AS count_subpoena diff --git a/mappings/country/main_dashboard.total_registered.ktr b/mappings/country/main_dashboard.total_registered.ktr index b3b26c1..ccfe1f7 100644 --- a/mappings/country/main_dashboard.total_registered.ktr +++ b/mappings/country/main_dashboard.total_registered.ktr @@ -662,23 +662,65 @@ postgres.person_registry - WITH recruit_data AS ( + WITH extracted_children AS ( + SELECT + ri.recruit_id, + jsonb_array_elements_text(ri.info->'svedDeti'->'rebenok') AS child + FROM + public.recruits_info ri + WHERE + jsonb_typeof(ri.info->'svedDeti'->'rebenok') = 'array' +), +children_birth_dates AS ( + SELECT + recruit_id, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'den')::int AS day, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'mesyacz')::int AS month, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'god')::int AS year + FROM + extracted_children +), +children_count AS ( + SELECT + recruit_id, + COUNT(*) AS children_under_16 + FROM + children_birth_dates + WHERE + AGE(make_date(year, month, day)) < interval '16 years' + GROUP BY + recruit_id +), +recruit_data AS ( SELECT COUNT(*) AS total_count, COUNT(*) FILTER (WHERE gender = 'MALE') AS male_count, COUNT(*) FILTER (WHERE gender = 'FEMALE') AS female_count, COUNT(*) FILTER ( WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 70 - AND gender = 'MALE') + AND gender = 'MALE') -- мужчины от 18 до 70 лет OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 45 - AND gender = 'FEMALE') + AND gender = 'FEMALE') -- женщины от 18 до 45 лет + AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки + AND COALESCE(cc.children_under_16, 0) < 5 -- исключить рекрутов с 5 и более детьми младше 16 лет ) AS mobilization_criterion, COUNT(*) FILTER ( WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30 - AND gender = 'MALE' - ) AS volunteer_criterion - FROM public.recruits r + AND gender = 'MALE' -- мужчины от 18 до 30 лет + AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки + ) AS volunteer_criterion, + COUNT(*) FILTER ( + WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 50 + AND gender = 'MALE' -- мужчины от 18 до 50 лет + AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки + AND ri.info->'svedSudim'->>'prOtsSvedSudim' = '1' -- признак отсутствия данных о судимости + ) AS contract_criterion + FROM public.recruits AS r + JOIN public.recruits_info AS ri + ON ri.recruit_id = r.id + LEFT JOIN children_count AS cc + ON r.id = cc.recruit_id WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'true' AND r.current_recruitment_id IS NOT NULL AND r.target_recruitment_id IS NOT NULL @@ -690,10 +732,10 @@ SELECT '00' AS recruitment_id, mobilization_criterion, volunteer_criterion, - 0 AS contract_criterion, - ROUND(mobilization_criterion::NUMERIC / total_count * 100, 2) AS mobilization_criterion_percent, - ROUND(volunteer_criterion::NUMERIC / total_count * 100, 2) AS volunteer_criterion_percent, -- неправильный критерий - 0 AS contract_criterion_percent + contract_criterion, + ROUND(mobilization_criterion::NUMERIC / NULLIF(total_count, 0) * 100, 2) AS mobilization_criterion_percent, + ROUND(volunteer_criterion::NUMERIC / NULLIF(total_count, 0) * 100, 2) AS volunteer_criterion_percent, + ROUND(contract_criterion::NUMERIC / NULLIF(total_count, 0) * 100, 2) AS contract_criterion_percent FROM recruit_data; 0 diff --git a/mappings/country/main_dashboard.waiting_registration.ktr b/mappings/country/main_dashboard.waiting_registration.ktr index 26dead1..9c28c1e 100644 --- a/mappings/country/main_dashboard.waiting_registration.ktr +++ b/mappings/country/main_dashboard.waiting_registration.ktr @@ -667,39 +667,81 @@ postgres.person_registry - WITH recruit_data AS ( + WITH extracted_children AS ( + SELECT + ri.recruit_id, + jsonb_array_elements_text(ri.info->'svedDeti'->'rebenok') AS child + FROM + public.recruits_info ri + WHERE + jsonb_typeof(ri.info->'svedDeti'->'rebenok') = 'array' +), +children_birth_dates AS ( + SELECT + recruit_id, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'den')::int AS day, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'mesyacz')::int AS month, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'god')::int AS year + FROM + extracted_children +), +children_count AS ( + SELECT + recruit_id, + COUNT(*) AS children_under_16 + FROM + children_birth_dates + WHERE + AGE(make_date(year, month, day)) < interval '16 years' + GROUP BY + recruit_id +), +recruit_data AS ( SELECT COUNT(*) AS waiting_count, COUNT(*) FILTER (WHERE gender = 'MALE') AS male_count, COUNT(*) FILTER (WHERE gender = 'FEMALE') AS female_count, COUNT(*) FILTER ( WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 70 - AND gender = 'MALE') + AND gender = 'MALE') -- мужчины от 18 до 70 лет OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 45 - AND gender = 'FEMALE') + AND gender = 'FEMALE') -- женщины от 18 до 45 лет + AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки + AND COALESCE(cc.children_under_16, 0) < 5 -- исключить рекрутов с 5 и более детьми младше 16 лет ) AS mobilization_criterion, COUNT(*) FILTER ( WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30 - AND gender = 'MALE' - ) AS volunteer_criterion - FROM public.recruits r + AND gender = 'MALE' -- мужчины от 18 до 30 лет + AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки + ) AS volunteer_criterion, + COUNT(*) FILTER ( + WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 50 + AND gender = 'MALE' -- мужчины от 18 до 50 лет + AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки + AND ri.info->'svedSudim'->>'prOtsSvedSudim' = '1' -- признак отсутствия данных о судимости + ) AS contract_criterion + FROM public.recruits AS r + JOIN public.recruits_info AS ri + ON ri.recruit_id = r.id + LEFT JOIN children_count AS cc + ON r.id = cc.recruit_id WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'false' AND r.current_recruitment_id IS NOT NULL AND r.target_recruitment_id IS NOT NULL ) SELECT waiting_count, + ROUND(COALESCE((waiting_count::DECIMAL / NULLIF((SELECT COUNT(*) FROM public.recruits), 0) * 100), 0), 2) AS waiting_percent, male_count, female_count, '00' AS recruitment_id, mobilization_criterion, volunteer_criterion, - 0 AS contract_criterion, - ROUND(mobilization_criterion::NUMERIC / waiting_count * 100, 2) AS mobilization_criterion_percent, - ROUND(volunteer_criterion::NUMERIC / waiting_count * 100, 2) AS volunteer_criterion_percent, - 0 AS contract_criterion_percent, - ROUND(COALESCE((waiting_count::DECIMAL / NULLIF((SELECT COUNT(*) FROM public.recruits), 0) * 100), 0), 2) AS waiting_percent + contract_criterion, + ROUND(mobilization_criterion::NUMERIC / NULLIF(waiting_count, 0) * 100, 2) AS mobilization_criterion_percent, + ROUND(volunteer_criterion::NUMERIC / NULLIF(waiting_count, 0) * 100, 2) AS volunteer_criterion_percent, + ROUND(contract_criterion::NUMERIC / NULLIF(waiting_count, 0) * 100, 2) AS contract_criterion_percent FROM recruit_data; 0 diff --git a/mappings/country/total_registered.driver_license.ktr b/mappings/country/total_registered.driver_license.ktr index e0d0fb1..a868cf2 100644 --- a/mappings/country/total_registered.driver_license.ktr +++ b/mappings/country/total_registered.driver_license.ktr @@ -915,35 +915,41 @@ SELECT r.id, r.gender, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "A")') AS has_A, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "B")') AS has_B, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "C")') AS has_C, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "D")') AS has_D, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "E")') AS has_E + -- Проверяем наличие хотя бы одной категории, используем DISTINCT для уникальных рекрутов + MAX(CASE WHEN cat->>'kategoriya' like '%A%' THEN 1 ELSE 0 END) AS has_A, + MAX(CASE WHEN cat->>'kategoriya' like '%B%' THEN 1 ELSE 0 END) AS has_B, + MAX(CASE WHEN cat->>'kategoriya' like '%C%' THEN 1 ELSE 0 END) AS has_C, + MAX(CASE WHEN cat->>'kategoriya' like '%D%' THEN 1 ELSE 0 END) AS has_D, + MAX(CASE WHEN cat->>'kategoriya' like '%E%' THEN 1 ELSE 0 END) AS has_E FROM public.recruits_info ri JOIN public.recruits r ON ri.recruit_id = r.id - where r.vu_current_info -> 'isMilitaryRegistered' = 'true' and r.current_recruitment_id is not null and r.target_recruitment_id is not null + LEFT JOIN jsonb_array_elements(ri.info->'svedVoditUdost'->'voditUdost'->'svedKat') AS cat ON true + WHERE r.vu_current_info->>'isMilitaryRegistered' = 'true' + AND r.current_recruitment_id IS NOT NULL + AND r.target_recruitment_id IS NOT NULL + GROUP BY r.id, r.gender ), aggregated AS ( SELECT 'ALL' AS gender, - '00' as recruitment_id, - COUNT(*) FILTER (WHERE NOT has_A AND NOT has_B AND NOT has_C AND NOT has_D AND NOT has_E) AS nope, - COUNT(*) FILTER (WHERE has_A) AS a, - COUNT(*) FILTER (WHERE has_B) AS b, - COUNT(*) FILTER (WHERE has_C) AS c, - COUNT(*) FILTER (WHERE has_D) AS d, - COUNT(*) FILTER (WHERE has_E) AS e, - COUNT(*) AS total - FROM categorized + '00' AS recruitment_id, + -- Считаем количество уникальных рекрутов с каждой категорией + COUNT(DISTINCT r.id) FILTER (WHERE has_A > 0) AS a, + COUNT(DISTINCT r.id) FILTER (WHERE has_B > 0) AS b, + COUNT(DISTINCT r.id) FILTER (WHERE has_C > 0) AS c, + COUNT(DISTINCT r.id) FILTER (WHERE has_D > 0) AS d, + COUNT(DISTINCT r.id) FILTER (WHERE has_E > 0) AS e, + COUNT(DISTINCT r.id) FILTER (WHERE has_A = 0 AND has_B = 0 AND has_C = 0 AND has_D = 0 AND has_E = 0) AS nope, + COUNT(DISTINCT r.id) AS total + FROM categorized r ) SELECT *, - ROUND((nope * 100.0) / NULLIF(total, 0), 2) AS nope_percent, ROUND((a * 100.0) / NULLIF(total, 0), 2) AS a_percent, ROUND((b * 100.0) / NULLIF(total, 0), 2) AS b_percent, ROUND((c * 100.0) / NULLIF(total, 0), 2) AS c_percent, ROUND((d * 100.0) / NULLIF(total, 0), 2) AS d_percent, - ROUND((e * 100.0) / NULLIF(total, 0), 2) AS e_percent + ROUND((e * 100.0) / NULLIF(total, 0), 2) AS e_percent, + ROUND((nope * 100.0) / NULLIF(total, 0), 2) AS nope_percent FROM aggregated; 0 @@ -980,35 +986,42 @@ FROM aggregated; SELECT r.id, r.gender, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "A")') AS has_A, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "B")') AS has_B, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "C")') AS has_C, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "D")') AS has_D, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "E")') AS has_E + -- Проверяем наличие хотя бы одной категории, используем DISTINCT для уникальных рекрутов + MAX(CASE WHEN cat->>'kategoriya' like '%A%' THEN 1 ELSE 0 END) AS has_A, + MAX(CASE WHEN cat->>'kategoriya' like '%B%' THEN 1 ELSE 0 END) AS has_B, + MAX(CASE WHEN cat->>'kategoriya' like '%C%' THEN 1 ELSE 0 END) AS has_C, + MAX(CASE WHEN cat->>'kategoriya' like '%D%' THEN 1 ELSE 0 END) AS has_D, + MAX(CASE WHEN cat->>'kategoriya' like '%E%' THEN 1 ELSE 0 END) AS has_E FROM public.recruits_info ri JOIN public.recruits r ON ri.recruit_id = r.id - where r.vu_current_info -> 'isMilitaryRegistered' = 'true' and gender = 'FEMALE' and r.current_recruitment_id is not null and r.target_recruitment_id is not null + LEFT JOIN jsonb_array_elements(ri.info->'svedVoditUdost'->'voditUdost'->'svedKat') AS cat ON true + WHERE r.vu_current_info->>'isMilitaryRegistered' = 'true' + AND r.current_recruitment_id IS NOT NULL + AND r.target_recruitment_id IS NOT NULL + AND r.gender = 'FEMALE' + GROUP BY r.id, r.gender ), aggregated AS ( SELECT 'W' AS gender, '00' as recruitment_id, - COUNT(*) FILTER (WHERE NOT has_A AND NOT has_B AND NOT has_C AND NOT has_D AND NOT has_E) AS nope, - COUNT(*) FILTER (WHERE has_A) AS a, - COUNT(*) FILTER (WHERE has_B) AS b, - COUNT(*) FILTER (WHERE has_C) AS c, - COUNT(*) FILTER (WHERE has_D) AS d, - COUNT(*) FILTER (WHERE has_E) AS e, - COUNT(*) AS total - FROM categorized + -- Считаем количество уникальных рекрутов с каждой категорией + COUNT(DISTINCT r.id) FILTER (WHERE has_A > 0) AS a, + COUNT(DISTINCT r.id) FILTER (WHERE has_B > 0) AS b, + COUNT(DISTINCT r.id) FILTER (WHERE has_C > 0) AS c, + COUNT(DISTINCT r.id) FILTER (WHERE has_D > 0) AS d, + COUNT(DISTINCT r.id) FILTER (WHERE has_E > 0) AS e, + COUNT(DISTINCT r.id) FILTER (WHERE has_A = 0 AND has_B = 0 AND has_C = 0 AND has_D = 0 AND has_E = 0) AS nope, + COUNT(DISTINCT r.id) AS total + FROM categorized r ) SELECT *, - ROUND((nope * 100.0) / NULLIF(total, 0), 2) AS nope_percent, ROUND((a * 100.0) / NULLIF(total, 0), 2) AS a_percent, ROUND((b * 100.0) / NULLIF(total, 0), 2) AS b_percent, ROUND((c * 100.0) / NULLIF(total, 0), 2) AS c_percent, ROUND((d * 100.0) / NULLIF(total, 0), 2) AS d_percent, - ROUND((e * 100.0) / NULLIF(total, 0), 2) AS e_percent + ROUND((e * 100.0) / NULLIF(total, 0), 2) AS e_percent, + ROUND((nope * 100.0) / NULLIF(total, 0), 2) AS nope_percent FROM aggregated; 0 @@ -1045,35 +1058,42 @@ FROM aggregated; SELECT r.id, r.gender, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "A")') AS has_A, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "B")') AS has_B, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "C")') AS has_C, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "D")') AS has_D, - jsonb_path_exists(ri.info, '$.svedVoditUdost.voditUdost.svedKat[*]?(@.kategoriya like_regex "E")') AS has_E + -- Проверяем наличие хотя бы одной категории, используем DISTINCT для уникальных рекрутов + MAX(CASE WHEN cat->>'kategoriya' like '%A%' THEN 1 ELSE 0 END) AS has_A, + MAX(CASE WHEN cat->>'kategoriya' like '%B%' THEN 1 ELSE 0 END) AS has_B, + MAX(CASE WHEN cat->>'kategoriya' like '%C%' THEN 1 ELSE 0 END) AS has_C, + MAX(CASE WHEN cat->>'kategoriya' like '%D%' THEN 1 ELSE 0 END) AS has_D, + MAX(CASE WHEN cat->>'kategoriya' like '%E%' THEN 1 ELSE 0 END) AS has_E FROM public.recruits_info ri JOIN public.recruits r ON ri.recruit_id = r.id - where r.vu_current_info -> 'isMilitaryRegistered' = 'true' and gender = 'MALE' and r.current_recruitment_id is not null and r.target_recruitment_id is not null + LEFT JOIN jsonb_array_elements(ri.info->'svedVoditUdost'->'voditUdost'->'svedKat') AS cat ON true + WHERE r.vu_current_info->>'isMilitaryRegistered' = 'true' + AND r.current_recruitment_id IS NOT NULL + AND r.target_recruitment_id IS NOT NULL + AND r.gender = 'MALE' + GROUP BY r.id, r.gender ), aggregated AS ( SELECT 'M' AS gender, '00' as recruitment_id, - COUNT(*) FILTER (WHERE NOT has_A AND NOT has_B AND NOT has_C AND NOT has_D AND NOT has_E) AS nope, - COUNT(*) FILTER (WHERE has_A) AS a, - COUNT(*) FILTER (WHERE has_B) AS b, - COUNT(*) FILTER (WHERE has_C) AS c, - COUNT(*) FILTER (WHERE has_D) AS d, - COUNT(*) FILTER (WHERE has_E) AS e, - COUNT(*) AS total - FROM categorized + -- Считаем количество уникальных рекрутов с каждой категорией + COUNT(DISTINCT r.id) FILTER (WHERE has_A > 0) AS a, + COUNT(DISTINCT r.id) FILTER (WHERE has_B > 0) AS b, + COUNT(DISTINCT r.id) FILTER (WHERE has_C > 0) AS c, + COUNT(DISTINCT r.id) FILTER (WHERE has_D > 0) AS d, + COUNT(DISTINCT r.id) FILTER (WHERE has_E > 0) AS e, + COUNT(DISTINCT r.id) FILTER (WHERE has_A = 0 AND has_B = 0 AND has_C = 0 AND has_D = 0 AND has_E = 0) AS nope, + COUNT(DISTINCT r.id) AS total + FROM categorized r ) SELECT *, - ROUND((nope * 100.0) / NULLIF(total, 0), 2) AS nope_percent, ROUND((a * 100.0) / NULLIF(total, 0), 2) AS a_percent, ROUND((b * 100.0) / NULLIF(total, 0), 2) AS b_percent, ROUND((c * 100.0) / NULLIF(total, 0), 2) AS c_percent, ROUND((d * 100.0) / NULLIF(total, 0), 2) AS d_percent, - ROUND((e * 100.0) / NULLIF(total, 0), 2) AS e_percent + ROUND((e * 100.0) / NULLIF(total, 0), 2) AS e_percent, + ROUND((nope * 100.0) / NULLIF(total, 0), 2) AS nope_percent FROM aggregated; 0 diff --git a/mappings/country/total_registered.removed_registry.ktr b/mappings/country/total_registered.removed_registry.ktr index 239a8db..0b4668f 100644 --- a/mappings/country/total_registered.removed_registry.ktr +++ b/mappings/country/total_registered.removed_registry.ktr @@ -555,80 +555,9 @@ - - postgres.person_registry - person-dbhost - POSTGRESQL - Native - person-dbname - 4444 - person-dbuser - Encrypted 2be98afb80fd5818ba554aa72ce93bcc9 - - - - - - FORCE_IDENTIFIERS_TO_LOWERCASE - N - - - FORCE_IDENTIFIERS_TO_UPPERCASE - N - - - IS_CLUSTERED - N - - - PORT_NUMBER - 4444 - - - PRESERVE_RESERVED_WORD_CASE - Y - - - QUOTE_ALL_FIELDS - N - - - SUPPORTS_BOOLEAN_DATA_TYPE - N - - - SUPPORTS_TIMESTAMP_DATA_TYPE - N - - - USE_POOLING - N - - - - - Table input 2 (person_registry) - Sort rows - Y - - - Sort rows - Merge join - Y - Table input (decision-document-service) РФ - Sort rows 2 - Y - - - Sort rows 2 - Merge join - Y - - - Merge join Insert / update (total_registered.removed_registry) Y @@ -683,7 +612,7 @@ living_abroad - travel_abroad + living_abroad Y @@ -736,126 +665,8 @@ - 1024 - 80 - Y - - - - Merge join - MergeJoin - - Y - - 1 - - none - - - FULL OUTER - Sort rows 2 - Sort rows - - org - - - org - - - - - - - - - - - 560 - 80 - Y - - - - Sort rows - SortRows - - Y - - 1 - - none - - - %%java.io.tmpdir%% - out - 1000000 - - N - - N - - - org - Y - N - N - 0 - N - - - - - - - - - - - - 448 - 192 - Y - - - - Sort rows 2 - SortRows - - Y - - 1 - - none - - - %%java.io.tmpdir%% - out - 1000000 - - N - - N - - - org - Y - N - N - 0 - N - - - - - - - - - - - - 464 - 80 + 912 + 224 Y @@ -871,56 +682,30 @@ postgres.decision-document-service - with t1 as -(select count(*) as age_limit -from public.decision d --(БД решений) -inner join public.decision_type dt on dt.id = d.type_id and dt.code = '9' -where d.extra_info -> 'cause' = '"ageLimit"') , -t2 as (select count(*) as death -from public.decision d --(БД решений) -inner join public.decision_type dt on dt.id = d.type_id and dt.code = '9' -where d.extra_info -> 'cause' = '"notAlive"') -select t1.age_limit, t2.death, 1 as org, '00' as recruitment_id, 0 as deprivation_citizenship, 0 as travel_abroad, 0 as living_abroad, 0 as other, -0 as deprivation_citizen_percents, 0 as age_limit_percent, 0 as death_percent, 0 as travel_abroad_percent, 0 as living_abroad_percent, 0 as other_percent -from t1 full outer join t2 on 1 = 1 - - 0 - - N - N - N - - - - - - - - - - 208 - 80 - Y - - - - Table input 2 (person_registry) - TableInput - - N - - 1 - - none - - - postgres.person_registry - SELECT COUNT(*) AS removed_registry, - 1 AS org -FROM public.recruits r + SELECT +COUNT(*) AS removed_registry, +COUNT(CASE WHEN d.extra_info ->> 'cause' = 'ageLimit' THEN 1 END) AS age_limit, -- Количество по причине предельный возраст +COUNT(CASE WHEN d.extra_info ->> 'cause' = 'notAlive' THEN 1 END) AS death, -- Количество по причине смерть +'0' AS deprivation_citizenship, +'0' AS travel_abroad, +'0' AS living_abroad, +'0' AS other, +'0' AS deprivation_citizen_percents, +ROUND(COUNT(CASE WHEN d.extra_info ->> 'cause' = 'ageLimit' THEN 1 END) * 100.0 / NULLIF(COUNT(*), 0), 2) AS age_limit_percent, +ROUND(COUNT(CASE WHEN d.extra_info ->> 'cause' = 'notAlive' THEN 1 END) * 100.0 / NULLIF(COUNT(*), 0), 2) AS death_percent, +'0' AS travel_abroad_percent, +'0' AS living_abroad_percent, +'0' AS other_percent, +'00' AS recruitment_id +FROM public.recruit AS r +JOIN public.decision AS d + ON d.recruit_id = r.id +JOIN public.decision_type AS dt + ON dt.id = d.type_id WHERE r.system_pgs_status = '1.3' - AND r.current_recruitment_id IS NOT NULL - AND r.target_recruitment_id IS NOT NULL + AND r.current_recruitment IS NOT NULL + AND r.target_recruitment IS NOT NULL + AND dt.code = '9' 0 N @@ -935,8 +720,8 @@ WHERE r.system_pgs_status = '1.3' - 208 - 192 + 464 + 224 Y diff --git a/mappings/info_recruits/job_info_recruits.kjb b/mappings/info_recruits/job_info_recruits.kjb index 4d450b4..f5872bf 100644 --- a/mappings/info_recruits/job_info_recruits.kjb +++ b/mappings/info_recruits/job_info_recruits.kjb @@ -360,8 +360,8 @@ N Y 0 - 320 - 432 + 368 + 624 @@ -372,8 +372,8 @@ N Y 0 - 1008 - 432 + 1056 + 624 @@ -410,8 +410,8 @@ N Y 0 - 736 - 112 + 784 + 256 @@ -428,8 +428,8 @@ N Y 0 - 592 - 112 + 640 + 256 @@ -446,8 +446,8 @@ N Y 0 - 592 - 48 + 640 + 192 @@ -464,8 +464,8 @@ N Y 0 - 592 - 176 + 640 + 320 @@ -482,8 +482,8 @@ N Y 0 - 592 - 240 + 640 + 384 @@ -520,8 +520,8 @@ N Y 0 - 736 - 48 + 784 + 192 @@ -558,8 +558,8 @@ N Y 0 - 736 - 176 + 784 + 320 @@ -596,8 +596,8 @@ N Y 0 - 736 - 240 + 784 + 384 @@ -614,8 +614,8 @@ N Y 0 - 592 - 304 + 640 + 448 @@ -652,8 +652,8 @@ N Y 0 - 736 - 304 + 784 + 448 @@ -670,8 +670,8 @@ N Y 0 - 592 - 368 + 640 + 512 @@ -708,8 +708,8 @@ N Y 0 - 736 - 368 + 784 + 512 @@ -726,8 +726,8 @@ N Y 0 - 592 - 432 + 640 + 576 @@ -764,8 +764,8 @@ N Y 0 - 736 - 432 + 784 + 576 @@ -782,8 +782,8 @@ N Y 0 - 592 - 496 + 640 + 640 @@ -820,8 +820,8 @@ N Y 0 - 736 - 496 + 784 + 640 @@ -838,8 +838,8 @@ N Y 0 - 592 - 560 + 640 + 704 @@ -876,8 +876,8 @@ N Y 0 - 736 - 560 + 784 + 704 @@ -894,8 +894,8 @@ N Y 0 - 592 - 624 + 640 + 768 @@ -932,8 +932,8 @@ N Y 0 - 736 - 624 + 784 + 768 @@ -950,8 +950,8 @@ N Y 0 - 592 - 688 + 640 + 832 @@ -988,8 +988,8 @@ N Y 0 - 736 - 688 + 784 + 832 @@ -1006,8 +1006,8 @@ N Y 0 - 592 - 752 + 640 + 896 @@ -1044,8 +1044,8 @@ N Y 0 - 736 - 752 + 784 + 896 @@ -1062,8 +1062,8 @@ N Y 0 - 592 - 816 + 640 + 960 @@ -1100,8 +1100,8 @@ N Y 0 - 736 - 816 + 784 + 960 @@ -1118,8 +1118,8 @@ N Y 0 - 592 - 880 + 640 + 1024 @@ -1156,8 +1156,8 @@ N Y 0 - 736 - 880 + 784 + 1024 @@ -1174,8 +1174,8 @@ N Y 0 - 592 - 944 + 640 + 1088 @@ -1212,8 +1212,120 @@ N Y 0 - 736 - 944 + 784 + 1088 + + + + SQL.subpoena + + SQL + + delete from ervu_dashboard.subpoena + F + F + + F + ervu-dashboard + N + Y + 0 + 640 + 1152 + + + + subpoena + + TRANS + + filename + + ${Internal.Entry.Current.Directory}/subpoena.ktr + + N + N + N + Y + N + N + + + N + N + Basic + N + + N + Y + N + N + N + Pentaho local + + Y + + N + Y + 0 + 784 + 1152 + + + + SQL.tempmeas + + SQL + + delete from ervu_dashboard.temporary_measures + F + F + + F + ervu-dashboard + N + Y + 0 + 640 + 1216 + + + + temporary_measure + + TRANS + + filename + + ${Internal.Entry.Current.Directory}/temporary_measure.ktr + + N + N + N + Y + N + N + + + N + N + Basic + N + + N + Y + N + N + N + Pentaho local + + Y + + N + Y + 0 + 784 + 1216 @@ -1623,6 +1735,60 @@ Y N + + SQL.subpoena + subpoena + 0 + 0 + Y + Y + N + + + subpoena + Success + 0 + 0 + Y + Y + N + + + Start + SQL.subpoena + 0 + 0 + Y + Y + Y + + + SQL.tempmeas + temporary_measure + 0 + 0 + Y + Y + N + + + Start + SQL.tempmeas + 0 + 0 + Y + Y + Y + + + temporary_measure + Success + 0 + 0 + Y + Y + N + diff --git a/mappings/info_recruits/subpoena.ktr b/mappings/info_recruits/subpoena.ktr new file mode 100644 index 0000000..88dae36 --- /dev/null +++ b/mappings/info_recruits/subpoena.ktr @@ -0,0 +1,691 @@ + + + + subpoena + + + + Normal + / + + + + + + + + + + + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + TRANSNAME + Y + TRANSNAME + + + STATUS + Y + STATUS + + + LINES_READ + Y + LINES_READ + + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + + LINES_UPDATED + Y + LINES_UPDATED + + + + LINES_INPUT + Y + LINES_INPUT + + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + + LINES_REJECTED + Y + LINES_REJECTED + + + + ERRORS + Y + ERRORS + + + STARTDATE + Y + STARTDATE + + + ENDDATE + Y + ENDDATE + + + LOGDATE + Y + LOGDATE + + + DEPDATE + Y + DEPDATE + + + REPLAYDATE + Y + REPLAYDATE + + + LOG_FIELD + Y + LOG_FIELD + + + EXECUTING_SERVER + N + EXECUTING_SERVER + + + EXECUTING_USER + N + EXECUTING_USER + + + CLIENT + N + CLIENT + + + + + +
+ + + + ID_BATCH + Y + ID_BATCH + + + SEQ_NR + Y + SEQ_NR + + + LOGDATE + Y + LOGDATE + + + TRANSNAME + Y + TRANSNAME + + + STEPNAME + Y + STEPNAME + + + STEP_COPY + Y + STEP_COPY + + + LINES_READ + Y + LINES_READ + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + LINES_UPDATED + Y + LINES_UPDATED + + + LINES_INPUT + Y + LINES_INPUT + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + LINES_REJECTED + Y + LINES_REJECTED + + + ERRORS + Y + ERRORS + + + INPUT_BUFFER_ROWS + Y + INPUT_BUFFER_ROWS + + + OUTPUT_BUFFER_ROWS + Y + OUTPUT_BUFFER_ROWS + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + LOGGING_OBJECT_TYPE + Y + LOGGING_OBJECT_TYPE + + + OBJECT_NAME + Y + OBJECT_NAME + + + OBJECT_COPY + Y + OBJECT_COPY + + + REPOSITORY_DIRECTORY + Y + REPOSITORY_DIRECTORY + + + FILENAME + Y + FILENAME + + + OBJECT_ID + Y + OBJECT_ID + + + OBJECT_REVISION + Y + OBJECT_REVISION + + + PARENT_CHANNEL_ID + Y + PARENT_CHANNEL_ID + + + ROOT_CHANNEL_ID + Y + ROOT_CHANNEL_ID + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + TRANSNAME + Y + TRANSNAME + + + STEPNAME + Y + STEPNAME + + + STEP_COPY + Y + STEP_COPY + + + LINES_READ + Y + LINES_READ + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + LINES_UPDATED + Y + LINES_UPDATED + + + LINES_INPUT + Y + LINES_INPUT + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + LINES_REJECTED + Y + LINES_REJECTED + + + ERRORS + Y + ERRORS + + + LOG_FIELD + N + LOG_FIELD + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + METRICS_DATE + Y + METRICS_DATE + + + METRICS_CODE + Y + METRICS_CODE + + + METRICS_DESCRIPTION + Y + METRICS_DESCRIPTION + + + METRICS_SUBJECT + Y + METRICS_SUBJECT + + + METRICS_TYPE + Y + METRICS_TYPE + + + METRICS_VALUE + Y + METRICS_VALUE + + + + + +
+ + 0.0 + 0.0 + + 10000 + 50 + 50 + N + Y + 50000 + Y + + N + 1000 + 100 + + + + + + + + + - + 2024/08/15 14:02:51.713 + - + 2024/08/15 14:02:51.713 + H4sIAAAAAAAAAAMAAAAAAAAAAAA= + N + + + + + ervu-dashboard + dashboard-dbhost + POSTGRESQL + Native + dashboard-dbname + 1111 + dashboard-dbuser + Encrypted 2daf9dca008c89396af54aa72ce93bcc9 + + + + + + EXTRA_OPTION_POSTGRESQL.stringtype + unspecified + + + FORCE_IDENTIFIERS_TO_LOWERCASE + N + + + FORCE_IDENTIFIERS_TO_UPPERCASE + N + + + IS_CLUSTERED + N + + + PORT_NUMBER + 1111 + + + PRESERVE_RESERVED_WORD_CASE + Y + + + QUOTE_ALL_FIELDS + N + + + SUPPORTS_BOOLEAN_DATA_TYPE + N + + + SUPPORTS_TIMESTAMP_DATA_TYPE + N + + + USE_POOLING + N + + + + + postgres.subpoena + subpoena-dbhost + POSTGRESQL + Native + subpoena-dbname + 5555 + subpoena-dbuser + Encrypted 2beebdaaa1ac8978aaa54aa72ce93bcc9 + + + + + + FORCE_IDENTIFIERS_TO_LOWERCASE + N + + + FORCE_IDENTIFIERS_TO_UPPERCASE + N + + + IS_CLUSTERED + N + + + PORT_NUMBER + 5555 + + + PRESERVE_RESERVED_WORD_CASE + Y + + + QUOTE_ALL_FIELDS + N + + + SUPPORTS_BOOLEAN_DATA_TYPE + N + + + SUPPORTS_TIMESTAMP_DATA_TYPE + N + + + USE_POOLING + N + + + + + + Table input + Table output + Y + + + + Table input + TableInput + + Y + + 1 + + none + + + postgres.subpoena + SELECT + s.id AS subpoena_id, -- идентификатор повестки + s.recruit_id, -- идентификатор рекрута + s.department_id, -- идентификатор ВК + s.series, -- серия повестки + s.create_date, -- дата создания повестки + s.number, -- номер повестки + s.send_date, -- дата направления повестки + s.sig_info, -- открепленная ЭП + sr.name AS subpoena_reason, -- причина вызова по повестке + s.full_name_responsible_user AS fio_commiss, -- фио комиссара + s.recruitment_name, -- наименование военного комиссариата, направившего повестку + rt.address, -- адрес, по которому нужно явиться по повестке + s.visit_date, -- дата и время явки в ВК + ssi.track_number, -- уникальный номер заказного почтового отправления, которым направлена повестка + ss.name AS subpoena_status, -- статус повестки + ssi.act_number, -- номер акта об отказе во вручении повестки + ssi.delivery_fio, -- фио лица, оповестившего гражданина о последствиях отказа от получения повестки + CASE + WHEN ssi.is_delivered = true THEN ssi.delivery_date + ELSE NULL + END AS delivery_date, -- дата вручения + CASE + WHEN ssi.is_delivered = true THEN 'Вручена' + WHEN ssi.is_delivered = false THEN 'Не вручена' + ELSE 'Нет информации' + END AS delivery_status, -- признак вручения повестки + CASE + WHEN sd.type = 'DIRECTION' THEN sd.name + ELSE NULL + END AS method_sending, -- способ направления повестки + CASE + WHEN sd.type = 'DELIVERY' THEN sd.name + ELSE NULL + END AS method_delivery, -- способ вручения повестки + CASE + WHEN sa.fact_appearance = true THEN 'Явился' + WHEN sa.fact_appearance = false THEN 'Не явился' + ELSE 'Нет информации' + END AS appearance_status, -- признак явки или неявки + CASE + WHEN ss.code = '5.1' THEN 'Неявка по уважительной причине' + WHEN ss.code = '5' THEN 'Гражданин не явился' + ELSE NULL + END AS appearance -- уважительная или нет причина +-- нет версии повестки +FROM public.subpoena AS s +LEFT JOIN public.subpoena_reason AS sr + ON sr.id = s.reason_id +LEFT JOIN public.recruitment AS rt + ON rt.id = s.department_id +LEFT JOIN public.subpoena_send_info AS ssi + ON ssi.subpoena_id = s.id +LEFT JOIN public.send_dictionary AS sd + ON sd.code = ssi.send_code +LEFT JOIN public.subpoena_status AS ss + ON ss.id = s.status_id +LEFT JOIN public.subpoena_appearance AS sa + ON sa.subpoena_id = s.id; + 0 + + N + N + N + + + + + + + + + + 208 + 208 + Y + + + + Table output + TableOutput + + Y + + 1 + + none + + + ervu-dashboard + ervu_dashboard +
subpoena
+ 1000 + N + N + Y + N + N + + N + Y + N + + Y + N + + + + + + + + + + + + + 416 + 208 + Y + + + + + + + N + +
diff --git a/mappings/info_recruits/temporary_measure.ktr b/mappings/info_recruits/temporary_measure.ktr new file mode 100644 index 0000000..566fb76 --- /dev/null +++ b/mappings/info_recruits/temporary_measure.ktr @@ -0,0 +1,674 @@ + + + + temporary_measure + + + + Normal + / + + + + + + + + + + + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + TRANSNAME + Y + TRANSNAME + + + STATUS + Y + STATUS + + + LINES_READ + Y + LINES_READ + + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + + LINES_UPDATED + Y + LINES_UPDATED + + + + LINES_INPUT + Y + LINES_INPUT + + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + + LINES_REJECTED + Y + LINES_REJECTED + + + + ERRORS + Y + ERRORS + + + STARTDATE + Y + STARTDATE + + + ENDDATE + Y + ENDDATE + + + LOGDATE + Y + LOGDATE + + + DEPDATE + Y + DEPDATE + + + REPLAYDATE + Y + REPLAYDATE + + + LOG_FIELD + Y + LOG_FIELD + + + EXECUTING_SERVER + N + EXECUTING_SERVER + + + EXECUTING_USER + N + EXECUTING_USER + + + CLIENT + N + CLIENT + + + + + +
+ + + + ID_BATCH + Y + ID_BATCH + + + SEQ_NR + Y + SEQ_NR + + + LOGDATE + Y + LOGDATE + + + TRANSNAME + Y + TRANSNAME + + + STEPNAME + Y + STEPNAME + + + STEP_COPY + Y + STEP_COPY + + + LINES_READ + Y + LINES_READ + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + LINES_UPDATED + Y + LINES_UPDATED + + + LINES_INPUT + Y + LINES_INPUT + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + LINES_REJECTED + Y + LINES_REJECTED + + + ERRORS + Y + ERRORS + + + INPUT_BUFFER_ROWS + Y + INPUT_BUFFER_ROWS + + + OUTPUT_BUFFER_ROWS + Y + OUTPUT_BUFFER_ROWS + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + LOGGING_OBJECT_TYPE + Y + LOGGING_OBJECT_TYPE + + + OBJECT_NAME + Y + OBJECT_NAME + + + OBJECT_COPY + Y + OBJECT_COPY + + + REPOSITORY_DIRECTORY + Y + REPOSITORY_DIRECTORY + + + FILENAME + Y + FILENAME + + + OBJECT_ID + Y + OBJECT_ID + + + OBJECT_REVISION + Y + OBJECT_REVISION + + + PARENT_CHANNEL_ID + Y + PARENT_CHANNEL_ID + + + ROOT_CHANNEL_ID + Y + ROOT_CHANNEL_ID + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + TRANSNAME + Y + TRANSNAME + + + STEPNAME + Y + STEPNAME + + + STEP_COPY + Y + STEP_COPY + + + LINES_READ + Y + LINES_READ + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + LINES_UPDATED + Y + LINES_UPDATED + + + LINES_INPUT + Y + LINES_INPUT + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + LINES_REJECTED + Y + LINES_REJECTED + + + ERRORS + Y + ERRORS + + + LOG_FIELD + N + LOG_FIELD + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + METRICS_DATE + Y + METRICS_DATE + + + METRICS_CODE + Y + METRICS_CODE + + + METRICS_DESCRIPTION + Y + METRICS_DESCRIPTION + + + METRICS_SUBJECT + Y + METRICS_SUBJECT + + + METRICS_TYPE + Y + METRICS_TYPE + + + METRICS_VALUE + Y + METRICS_VALUE + + + + + +
+ + 0.0 + 0.0 + + 10000 + 50 + 50 + N + Y + 50000 + Y + + N + 1000 + 100 + + + + + + + + + - + 2024/08/15 14:02:51.713 + - + 2024/08/15 14:02:51.713 + H4sIAAAAAAAAAAMAAAAAAAAAAAA= + N + + + + + ervu-dashboard + dashboard-dbhost + POSTGRESQL + Native + dashboard-dbname + 1111 + dashboard-dbuser + Encrypted 2daf9dca008c89396af54aa72ce93bcc9 + + + + + + EXTRA_OPTION_POSTGRESQL.stringtype + unspecified + + + FORCE_IDENTIFIERS_TO_LOWERCASE + N + + + FORCE_IDENTIFIERS_TO_UPPERCASE + N + + + IS_CLUSTERED + N + + + PORT_NUMBER + 1111 + + + PRESERVE_RESERVED_WORD_CASE + Y + + + QUOTE_ALL_FIELDS + N + + + SUPPORTS_BOOLEAN_DATA_TYPE + N + + + SUPPORTS_TIMESTAMP_DATA_TYPE + N + + + USE_POOLING + N + + + + + postgres.subpoena + subpoena-dbhost + POSTGRESQL + Native + subpoena-dbname + 5555 + subpoena-dbuser + Encrypted 2beebdaaa1ac8978aaa54aa72ce93bcc9 + + + + + + FORCE_IDENTIFIERS_TO_LOWERCASE + N + + + FORCE_IDENTIFIERS_TO_UPPERCASE + N + + + IS_CLUSTERED + N + + + PORT_NUMBER + 5555 + + + PRESERVE_RESERVED_WORD_CASE + Y + + + QUOTE_ALL_FIELDS + N + + + SUPPORTS_BOOLEAN_DATA_TYPE + N + + + SUPPORTS_TIMESTAMP_DATA_TYPE + N + + + USE_POOLING + N + + + + + + Table input + Table output + Y + + + + Table input + TableInput + + Y + + 1 + + none + + + postgres.subpoena + SELECT + rd.subpoena_id, + rd.vk_id AS recruitment_id, + s.recruit_id, + rds.name AS status_measure, -- статус временной меры + rd.recruitment_name, -- наименоване ВК + rdi.cancel_date, -- дата, с которой отменена временная мера + rn.name AS restriction_name, -- наименование ограничения (тип временной меры) + CASE + WHEN rd.type='CREATE' THEN 'Применение временной меры' + WHEN rd.type='CANCEL' THEN 'Отмена временной меры' + END AS type, -- тип документа ограничения + CASE + WHEN rd.type='CREATE' THEN rd.decision_number + ELSE NULL + END AS decision_number_create, -- номер решения о применении временной меры + CASE + WHEN rd.type='CANCEL' THEN rd.decision_number + ELSE NULL + END AS decision_number_cancel, -- номер решения об отмене временной меры + CASE + WHEN rd.type='CREATE' THEN rd.decision_date + ELSE NULL + END AS decision_date_create, -- дата решения о применении временной меры + CASE + WHEN rd.type='CANCEL' THEN rd.decision_date + ELSE NULL + END AS decision_date_cancel, -- дата решения об отмене временной меры + CASE + WHEN rdi.applied_fact = 'true' THEN 'Временная мера применена' + WHEN rdi.applied_fact = 'false' THEN 'Временная мера не применена' + ELSE 'Нет информации' + END AS applied_fact -- факт применения временной меры +FROM public.restriction_document AS rd +LEFT JOIN public.restriction_document_item AS rdi + ON rdi.restriction_document_create_id = rd.id +LEFT JOIN public.restriction AS rn + ON rn.id = rdi.restriction_id +LEFT JOIN public.restriction_document_status AS rds + ON rds.code = rd.status +LEFT JOIN public.subpoena AS s + ON s.id = rd.subpoena_id + 0 + + N + N + N + + + + + + + + + + 208 + 208 + Y + + + + Table output + TableOutput + + Y + + 1 + + none + + + ervu-dashboard + ervu_dashboard +
temporary_measures
+ 1000 + N + N + Y + N + N + + N + Y + N + + Y + N + + + + + + + + + + + + + 416 + 208 + Y + + + + + + + N + +
diff --git a/mappings/region/main_dashboard.total_registered(reg).ktr b/mappings/region/main_dashboard.total_registered(reg).ktr index e923737..b1322c4 100644 --- a/mappings/region/main_dashboard.total_registered(reg).ktr +++ b/mappings/region/main_dashboard.total_registered(reg).ktr @@ -785,46 +785,106 @@ postgres.person_registry - WITH recruit_data AS ( - SELECT - COUNT(*) AS total_count, - COUNT(*) FILTER (WHERE gender = 'MALE') AS male_count, - COUNT(*) FILTER (WHERE gender = 'FEMALE') AS female_count - FROM public.recruits r - WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'true' - AND r.current_recruitment_id IS NOT NULL - AND ( - '${VK_ARRAY}' IS NULL - OR '${VK_ARRAY}' = '' - OR r.target_recruitment_id = ANY ( - CASE + WITH extracted_children AS ( + SELECT + ri.recruit_id, + jsonb_array_elements_text(ri.info->'svedDeti'->'rebenok') AS child + FROM public.recruits AS r + JOIN public.recruits_info AS ri + ON ri.recruit_id = r.id + WHERE + jsonb_typeof(ri.info->'svedDeti'->'rebenok') = 'array' + AND r.vu_current_info ->> 'isMilitaryRegistered' = 'true' + AND r.current_recruitment_id IS NOT NULL + AND ( + '${VK_ARRAY}' IS NOT NULL AND '${VK_ARRAY}' != '' + AND r.target_recruitment_id = ANY ( + CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN ARRAY[]::uuid[] ELSE string_to_array(trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',')::uuid[] END ) ) -) +), +children_birth_dates AS ( + SELECT + recruit_id, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'den')::int AS day, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'mesyacz')::int AS month, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'god')::int AS year + FROM extracted_children +), +children_count AS ( + SELECT + recruit_id, + COUNT(*) AS children_under_16 + FROM children_birth_dates + WHERE AGE(make_date(year, month, day)) < interval '16 years' + GROUP BY recruit_id +), +recruit_data AS ( + SELECT + COUNT(*) AS total_count, + COUNT(*) FILTER (WHERE gender = 'MALE') AS male_count, + COUNT(*) FILTER (WHERE gender = 'FEMALE') AS female_count, + COUNT(*) FILTER ( + WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 70 + AND gender = 'MALE') + OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 45 + AND gender = 'FEMALE') + AND (conscription IS NULL OR conscription = false) + AND COALESCE(cc.children_under_16, 0) < 5 + ) AS mobilization_criterion, + COUNT(*) FILTER ( + WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30 + AND gender = 'MALE' + AND (conscription IS NULL OR conscription = false) + ) AS volunteer_criterion, + COUNT(*) FILTER ( + WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 50 + AND gender = 'MALE' + AND (conscription IS NULL OR conscription = false) + AND ri.info->'svedSudim'->>'prOtsSvedSudim' = '1' + ) AS contract_criterion + FROM public.recruits AS r + JOIN public.recruits_info AS ri + ON ri.recruit_id = r.id + LEFT JOIN children_count AS cc + ON r.id = cc.recruit_id + WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'true' + AND r.current_recruitment_id IS NOT NULL + AND ( + '${VK_ARRAY}' IS NOT NULL AND '${VK_ARRAY}' != '' + AND r.target_recruitment_id = ANY ( + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN ARRAY[]::uuid[] + ELSE string_to_array(trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',')::uuid[] + END + ) + ) +) SELECT + '${REG_ID}' AS recruitment_id, + COALESCE(rd.total_count, 0) AS total_count, + COALESCE(rd.male_count, 0) AS male_count, + COALESCE(rd.female_count, 0) AS female_count, + COALESCE(rd.mobilization_criterion, 0) AS mobilization_criterion, + COALESCE(rd.volunteer_criterion, 0) AS volunteer_criterion, + COALESCE(rd.contract_criterion, 0) AS contract_criterion, CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE rd.total_count - END AS total_count, + WHEN rd.total_count > 0 THEN ROUND(rd.mobilization_criterion::NUMERIC / rd.total_count * 100, 2) + ELSE 0 + END AS mobilization_criterion_percent, CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE rd.male_count - END AS male_count, + WHEN rd.total_count > 0 THEN ROUND(rd.volunteer_criterion::NUMERIC / rd.total_count * 100, 2) + ELSE 0 + END AS volunteer_criterion_percent, CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE rd.female_count - END AS female_count, - '${REG_ID}' AS recruitment_id, - 0 AS mobilization_criterion, - 0 AS volunteer_criterion, - 0 AS contract_criterion, - 0 AS mobilization_criterion_percent, - 0 AS volunteer_criterion_percent, - 0 AS contract_criterion_percent -FROM recruit_data rd; + WHEN rd.total_count > 0 THEN ROUND(rd.contract_criterion::NUMERIC / rd.total_count * 100, 2) + ELSE 0 + END AS contract_criterion_percent +FROM recruit_data AS rd; + 0 N diff --git a/mappings/region/main_dashboard.waiting_registration(reg).ktr b/mappings/region/main_dashboard.waiting_registration(reg).ktr index ba3bc3b..6068a36 100644 --- a/mappings/region/main_dashboard.waiting_registration(reg).ktr +++ b/mappings/region/main_dashboard.waiting_registration(reg).ktr @@ -696,6 +696,11 @@ recruitment_id N
+ + waiting_registration_percent + waiting_percent + Y +
@@ -785,30 +790,113 @@ postgres.person_registry - SELECT - CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COUNT(*) END AS waiting_count, - CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COUNT(*) FILTER (WHERE gender = 'MALE') END AS male_count, - CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COUNT(*) FILTER (WHERE gender = 'FEMALE') END AS female_count, - '${REG_ID}' AS recruitment_id, - 0 AS mobilization_criterion, - 0 AS volunteer_criterion, - 0 AS contract_criterion, - 0 AS mobilization_criterion_percent, - 0 AS volunteer_criterion_percent, - 0 AS contract_criterion_percent, - CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE ROUND(COALESCE((COUNT(*)::DECIMAL / NULLIF((SELECT COUNT(*) FROM public.recruits), 0) * 100), 0), 2) END AS waiting_percent -FROM public.recruits r -WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'false' - AND r.current_recruitment_id IS NOT NULL - AND ( - '${VK_ARRAY}' IS NULL - OR '${VK_ARRAY}' = '' - OR r.target_recruitment_id = ANY ( - string_to_array( - trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' - )::uuid[] + WITH extracted_children AS ( + SELECT + ri.recruit_id, + jsonb_array_elements_text(ri.info->'svedDeti'->'rebenok') AS child + FROM public.recruits AS r + JOIN public.recruits_info AS ri + ON ri.recruit_id = r.id + WHERE + jsonb_typeof(ri.info->'svedDeti'->'rebenok') = 'array' + AND r.vu_current_info ->> 'isMilitaryRegistered' = 'true' + AND r.current_recruitment_id IS NOT NULL + AND ( + '${VK_ARRAY}' IS NOT NULL AND '${VK_ARRAY}' != '' + AND r.target_recruitment_id = ANY ( + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN ARRAY[]::uuid[] + ELSE string_to_array(trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',')::uuid[] + END + ) ) - ); +), +children_birth_dates AS ( + SELECT + recruit_id, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'den')::int AS day, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'mesyacz')::int AS month, + (child::jsonb->'svedFLBS'->'dataRozhdDok'->>'god')::int AS year + FROM extracted_children +), +children_count AS ( + SELECT + recruit_id, + COUNT(*) AS children_under_16 + FROM children_birth_dates + WHERE AGE(make_date(year, month, day)) < interval '16 years' + GROUP BY recruit_id +), +recruit_data AS ( + SELECT + COUNT(*) AS waiting_count, + COUNT(*) FILTER (WHERE gender = 'MALE') AS male_count, + COUNT(*) FILTER (WHERE gender = 'FEMALE') AS female_count, + COUNT(*) FILTER ( + WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 70 AND gender = 'MALE') + OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 45 AND gender = 'FEMALE') + AND (conscription IS NULL OR conscription = false) + AND COALESCE(cc.children_under_16, 0) < 5 + ) AS mobilization_criterion, + COUNT(*) FILTER ( + WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30 + AND gender = 'MALE' + AND (conscription IS NULL OR conscription = false) + ) AS volunteer_criterion, + COUNT(*) FILTER ( + WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 50 + AND gender = 'MALE' + AND (conscription IS NULL OR conscription = false) + AND ri.info->'svedSudim'->>'prOtsSvedSudim' = '1' + ) AS contract_criterion + FROM public.recruits AS r + JOIN public.recruits_info AS ri + ON ri.recruit_id = r.id + LEFT JOIN children_count AS cc + ON r.id = cc.recruit_id + WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'true' + AND r.current_recruitment_id IS NOT NULL + AND ( + '${VK_ARRAY}' IS NOT NULL AND '${VK_ARRAY}' != '' + AND r.target_recruitment_id = ANY ( + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN ARRAY[]::uuid[] + ELSE string_to_array(trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',')::uuid[] + END + ) + ) +) +SELECT + '${REG_ID}' AS recruitment_id, + COALESCE(rd.waiting_count, 0) AS waiting_count, + COALESCE(rd.male_count, 0) AS male_count, + COALESCE(rd.female_count, 0) AS female_count, + COALESCE(rd.mobilization_criterion, 0) AS mobilization_criterion, + COALESCE(rd.volunteer_criterion, 0) AS volunteer_criterion, + COALESCE(rd.contract_criterion, 0) AS contract_criterion, + CASE + WHEN rd.waiting_count > 0 THEN ROUND(rd.mobilization_criterion::NUMERIC / rd.waiting_count * 100, 2) + ELSE 0 + END AS mobilization_criterion_percent, + CASE + WHEN rd.waiting_count > 0 THEN ROUND(rd.volunteer_criterion::NUMERIC / rd.waiting_count * 100, 2) + ELSE 0 + END AS volunteer_criterion_percent, + CASE + WHEN rd.waiting_count > 0 THEN ROUND(rd.contract_criterion::NUMERIC / rd.waiting_count * 100, 2) + ELSE 0 + END AS contract_criterion_percent, + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE ROUND( + COALESCE( + (rd.waiting_count::DECIMAL / NULLIF( + (SELECT COUNT(*) FROM public.recruits WHERE vu_current_info ->> 'isMilitaryRegistered' = 'true'), 0) * 100 + ), 0 + ), 2 + ) + END AS waiting_percent +FROM recruit_data AS rd; 0 N diff --git a/mappings/region/total_registered.age(reg).ktr b/mappings/region/total_registered.age(reg).ktr index 2a04f42..d4382bf 100644 --- a/mappings/region/total_registered.age(reg).ktr +++ b/mappings/region/total_registered.age(reg).ktr @@ -800,6 +800,159 @@ Y + + Get variables 3 2 2 2 2 + GetVariable + + Y + + 1 + + none + + + + + REG_ID + + String + + + + + -1 + -1 + none + + + VK_ARRAY + + String + + + + + -1 + -1 + none + + + + + + + + + + + + 656 + 1056 + Y + + + + Get variables 3 2 2 3 + GetVariable + + Y + + 1 + + none + + + + + REG_ID + + String + + + + + -1 + -1 + none + + + VK_ARRAY + + String + + + + + -1 + -1 + none + + + + + + + + + + + + 656 + 896 + Y + + + + Get variables 3 2 3 + GetVariable + + Y + + 1 + + none + + + + + REG_ID + + String + + + + + -1 + -1 + none + + + VK_ARRAY + + String + + + + + -1 + -1 + none + + + + + + + + + + + + 656 + 736 + Y + + Insert / update (total_registered.age) InsertUpdate @@ -1066,6 +1219,139 @@ Y + + Insert / update (total_registered.age) 2 2 + InsertUpdate + + Y + + 1 + + none + + + ervu-dashboard + 100 + Y + + total_registered + age
+ + REG_ID + recruitment_id + = + + + + "17_yaers" + 17_year_count + Y + + + "18-26_years" + 18-26_year_count + Y + + + "27-30_years" + 27-30_year_count + Y + + + "31-35_years" + 31-35_year_count + Y + + + "36-40_years" + 36-40_year_count + Y + + + "41-45_years" + 41-45_year_count + Y + + + "51+_years" + 41-45_year_count + Y + + + "all_M_W" + gender + N + + + "46-50_years" + 46-50_year_count + Y + + + "17_yaers_percent" + 17_year_percent + Y + + + "18-26_years_percent" + 18-26_year_percent + Y + + + "27-30_years_percent" + 27-30_year_percent + Y + + + "31-35_years_percent" + 31-35_year_percent + Y + + + "36-40_years_percent" + 36-40_year_percent + Y + + + "41-45_years_percent" + 41-45_year_percent + Y + + + "46-50_years_percent" + 46-50_year_percent + Y + + + "51+_years_percent" + 51+_year_percent + Y + + + recruitment_id + recruitment_id + N + + + registered + registered + N + +
+ + + + + + + + + + 1040 + 896 + Y + +
Insert / update (total_registered.age) 3 InsertUpdate @@ -1199,6 +1485,272 @@ Y + + Insert / update (total_registered.age) 3 2 + InsertUpdate + + Y + + 1 + + none + + + ervu-dashboard + 100 + Y + + total_registered + age
+ + REG_ID + recruitment_id + = + + + + "17_yaers" + 17_year_count + Y + + + "18-26_years" + 18-26_year_count + Y + + + "27-30_years" + 27-30_year_count + Y + + + "31-35_years" + 31-35_year_count + Y + + + "36-40_years" + 36-40_year_count + Y + + + "41-45_years" + 41-45_year_count + Y + + + "51+_years" + 41-45_year_count + Y + + + "all_M_W" + gender + N + + + "46-50_years" + 46-50_year_count + Y + + + "17_yaers_percent" + 17_year_percent + Y + + + "18-26_years_percent" + 18-26_year_percent + Y + + + "27-30_years_percent" + 27-30_year_percent + Y + + + "31-35_years_percent" + 31-35_year_percent + Y + + + "36-40_years_percent" + 36-40_year_percent + Y + + + "41-45_years_percent" + 41-45_year_percent + Y + + + "46-50_years_percent" + 46-50_year_percent + Y + + + "51+_years_percent" + 51+_year_percent + Y + + + recruitment_id + recruitment_id + N + + + registered + registered + N + +
+ + + + + + + + + + 1056 + 1056 + Y + +
+ + Insert / update (total_registered.age) 4 + InsertUpdate + + Y + + 1 + + none + + + ervu-dashboard + 100 + Y + + total_registered + age
+ + REG_ID + recruitment_id + = + + + + "17_yaers" + 17_year_count + Y + + + "18-26_years" + 18-26_year_count + Y + + + "27-30_years" + 27-30_year_count + Y + + + "31-35_years" + 31-35_year_count + Y + + + "36-40_years" + 36-40_year_count + Y + + + "41-45_years" + 41-45_year_count + Y + + + "51+_years" + 41-45_year_count + Y + + + "all_M_W" + gender + N + + + "46-50_years" + 46-50_year_count + Y + + + "17_yaers_percent" + 17_year_percent + Y + + + "18-26_years_percent" + 18-26_year_percent + Y + + + "27-30_years_percent" + 27-30_year_percent + Y + + + "31-35_years_percent" + 31-35_year_percent + Y + + + "36-40_years_percent" + 36-40_year_percent + Y + + + "41-45_years_percent" + 41-45_year_percent + Y + + + "46-50_years_percent" + 46-50_year_percent + Y + + + "51+_years_percent" + 51+_year_percent + Y + + + recruitment_id + recruitment_id + N + + + registered + registered + N + +
+ + + + + + + + + + 1040 + 736 + Y + +
Select values 3 2 SelectValues @@ -1385,6 +1937,192 @@ Y + + Select values 3 2 2 2 2 + SelectValues + + Y + + 1 + + none + + + + N + + REG_ID + REG_ID + String + -2 + -2 + + false + + + false + + + + + + + + VK_ARRAY + VK_ARRAY + String + -2 + -2 + + false + + + false + + + + + + + + + + + + + + + + + 800 + 1056 + Y + + + + Select values 3 2 2 3 + SelectValues + + Y + + 1 + + none + + + + N + + REG_ID + REG_ID + String + -2 + -2 + + false + + + false + + + + + + + + VK_ARRAY + VK_ARRAY + String + -2 + -2 + + false + + + false + + + + + + + + + + + + + + + + + 800 + 896 + Y + + + + Select values 3 2 3 + SelectValues + + Y + + 1 + + none + + + + N + + REG_ID + REG_ID + String + -2 + -2 + + false + + + false + + + + + + + + VK_ARRAY + VK_ARRAY + String + -2 + -2 + + false + + + false + + + + + + + + + + + + + + + + + 800 + 736 + Y + + Table input (person_registry) регион/все TableInput @@ -1513,6 +2251,134 @@ FROM age_counts, total_count; Y + + Table input (person_registry) регион/все 2 + TableInput + + Y + + 1 + + none + + + ervu_person_registry + WITH total_count AS ( + SELECT + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) + END AS total + FROM public.recruits r + JOIN public.recruits_info ri ON ri.recruit_id = r.id + WHERE r.vu_current_info->>'isMilitaryRegistered' = 'false' + AND r.current_recruitment_id IS NOT NULL + AND ( + '${VK_ARRAY}' IS NULL + OR '${VK_ARRAY}' = '' + OR r.target_recruitment_id = ANY ( + string_to_array( + trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' + )::uuid[] + ) + ) +), +age_counts AS ( + SELECT + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) = 17) + END AS "17_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 18 AND 26) + END AS "18-26_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 27 AND 30) + END AS "27-30_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 31 AND 35) + END AS "31-35_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 36 AND 40) + END AS "36-40_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 41 AND 45) + END AS "41-45_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 46 AND 50) + END AS "46-50_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) >= 51) + END AS "51+_year_count" + FROM public.recruits r + JOIN public.recruits_info ri ON ri.recruit_id = r.id + WHERE r.vu_current_info->>'isMilitaryRegistered' = 'false' + AND r.current_recruitment_id IS NOT NULL + AND ( + '${VK_ARRAY}' IS NULL + OR '${VK_ARRAY}' = '' + OR r.target_recruitment_id = ANY ( + string_to_array( + trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' + )::uuid[] + ) + ) +) +SELECT + age_counts."17_year_count", + ROUND((age_counts."17_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "17_year_percent", + + age_counts."18-26_year_count", + ROUND((age_counts."18-26_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "18-26_year_percent", + + age_counts."27-30_year_count", + ROUND((age_counts."27-30_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "27-30_year_percent", + + age_counts."31-35_year_count", + ROUND((age_counts."31-35_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "31-35_year_percent", + + age_counts."36-40_year_count", + ROUND((age_counts."36-40_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "36-40_year_percent", + + age_counts."41-45_year_count", + ROUND((age_counts."41-45_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "41-45_year_percent", + + age_counts."46-50_year_count", + ROUND((age_counts."46-50_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "46-50_year_percent", + + age_counts."51+_year_count", + ROUND((age_counts."51+_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "51+_year_percent", + + '${REG_ID}' AS recruitment_id, + 'ALL' AS gender, + 'false' AS registered +FROM age_counts, total_count; + 0 + + N + Y + N + + + + + + + + + + 416 + 736 + Y + + Table input (person_registry) регион/женщины TableInput @@ -1643,1002 +2509,6 @@ FROM age_counts, total_count; Y - - Table input (person_registry) регион/мужчины - TableInput - - Y - - 1 - - none - - - ervu_person_registry - WITH total_count AS ( - SELECT - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) - END AS total - FROM public.recruits r - JOIN public.recruits_info ri ON ri.recruit_id = r.id - WHERE r.vu_current_info->>'isMilitaryRegistered' = 'true' - AND r.current_recruitment_id IS NOT NULL - AND r.gender = 'MALE' - AND ( - '${VK_ARRAY}' IS NULL - OR '${VK_ARRAY}' = '' - OR r.target_recruitment_id = ANY ( - string_to_array( - trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' - )::uuid[] - ) - ) -), -age_counts AS ( - SELECT - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) = 17) - END AS "17_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 18 AND 26) - END AS "18-26_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 27 AND 30) - END AS "27-30_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 31 AND 35) - END AS "31-35_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 36 AND 40) - END AS "36-40_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 41 AND 45) - END AS "41-45_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 46 AND 50) - END AS "46-50_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) >= 51) - END AS "51+_year_count" - FROM public.recruits r - JOIN public.recruits_info ri ON ri.recruit_id = r.id - WHERE r.vu_current_info->>'isMilitaryRegistered' = 'true' - AND r.gender = 'MALE' - AND r.current_recruitment_id IS NOT NULL - AND ( - '${VK_ARRAY}' IS NULL - OR '${VK_ARRAY}' = '' - OR r.target_recruitment_id = ANY ( - string_to_array( - trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' - )::uuid[] - ) - ) -) -SELECT - age_counts."17_year_count", - ROUND((age_counts."17_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "17_year_percent", - - age_counts."18-26_year_count", - ROUND((age_counts."18-26_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "18-26_year_percent", - - age_counts."27-30_year_count", - ROUND((age_counts."27-30_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "27-30_year_percent", - - age_counts."31-35_year_count", - ROUND((age_counts."31-35_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "31-35_year_percent", - - age_counts."36-40_year_count", - ROUND((age_counts."36-40_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "36-40_year_percent", - - age_counts."41-45_year_count", - ROUND((age_counts."41-45_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "41-45_year_percent", - - age_counts."46-50_year_count", - ROUND((age_counts."46-50_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "46-50_year_percent", - - age_counts."51+_year_count", - ROUND((age_counts."51+_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "51+_year_percent", - - '${REG_ID}' AS recruitment_id, - 'M' AS gender, - 'true' AS registered -FROM age_counts, total_count; - 0 - - N - Y - N - - - - - - - - - - 432 - 352 - Y - - - - Get variables 3 2 3 - GetVariable - - Y - - 1 - - none - - - - - REG_ID - - String - - - - - -1 - -1 - none - - - VK_ARRAY - - String - - - - - -1 - -1 - none - - - - - - - - - - - - 656 - 736 - Y - - - - Get variables 3 2 2 3 - GetVariable - - Y - - 1 - - none - - - - - REG_ID - - String - - - - - -1 - -1 - none - - - VK_ARRAY - - String - - - - - -1 - -1 - none - - - - - - - - - - - - 656 - 896 - Y - - - - Get variables 3 2 2 2 2 - GetVariable - - Y - - 1 - - none - - - - - REG_ID - - String - - - - - -1 - -1 - none - - - VK_ARRAY - - String - - - - - -1 - -1 - none - - - - - - - - - - - - 656 - 1056 - Y - - - - Insert / update (total_registered.age) 4 - InsertUpdate - - Y - - 1 - - none - - - ervu-dashboard - 100 - Y - - total_registered - age
- - REG_ID - recruitment_id - = - - - - "17_yaers" - 17_year_count - Y - - - "18-26_years" - 18-26_year_count - Y - - - "27-30_years" - 27-30_year_count - Y - - - "31-35_years" - 31-35_year_count - Y - - - "36-40_years" - 36-40_year_count - Y - - - "41-45_years" - 41-45_year_count - Y - - - "51+_years" - 41-45_year_count - Y - - - "all_M_W" - gender - N - - - "46-50_years" - 46-50_year_count - Y - - - "17_yaers_percent" - 17_year_percent - Y - - - "18-26_years_percent" - 18-26_year_percent - Y - - - "27-30_years_percent" - 27-30_year_percent - Y - - - "31-35_years_percent" - 31-35_year_percent - Y - - - "36-40_years_percent" - 36-40_year_percent - Y - - - "41-45_years_percent" - 41-45_year_percent - Y - - - "46-50_years_percent" - 46-50_year_percent - Y - - - "51+_years_percent" - 51+_year_percent - Y - - - recruitment_id - recruitment_id - N - - - registered - registered - N - -
- - - - - - - - - - 1040 - 736 - Y - -
- - Insert / update (total_registered.age) 2 2 - InsertUpdate - - Y - - 1 - - none - - - ervu-dashboard - 100 - Y - - total_registered - age
- - REG_ID - recruitment_id - = - - - - "17_yaers" - 17_year_count - Y - - - "18-26_years" - 18-26_year_count - Y - - - "27-30_years" - 27-30_year_count - Y - - - "31-35_years" - 31-35_year_count - Y - - - "36-40_years" - 36-40_year_count - Y - - - "41-45_years" - 41-45_year_count - Y - - - "51+_years" - 41-45_year_count - Y - - - "all_M_W" - gender - N - - - "46-50_years" - 46-50_year_count - Y - - - "17_yaers_percent" - 17_year_percent - Y - - - "18-26_years_percent" - 18-26_year_percent - Y - - - "27-30_years_percent" - 27-30_year_percent - Y - - - "31-35_years_percent" - 31-35_year_percent - Y - - - "36-40_years_percent" - 36-40_year_percent - Y - - - "41-45_years_percent" - 41-45_year_percent - Y - - - "46-50_years_percent" - 46-50_year_percent - Y - - - "51+_years_percent" - 51+_year_percent - Y - - - recruitment_id - recruitment_id - N - - - registered - registered - N - -
- - - - - - - - - - 1040 - 896 - Y - -
- - Insert / update (total_registered.age) 3 2 - InsertUpdate - - Y - - 1 - - none - - - ervu-dashboard - 100 - Y - - total_registered - age
- - REG_ID - recruitment_id - = - - - - "17_yaers" - 17_year_count - Y - - - "18-26_years" - 18-26_year_count - Y - - - "27-30_years" - 27-30_year_count - Y - - - "31-35_years" - 31-35_year_count - Y - - - "36-40_years" - 36-40_year_count - Y - - - "41-45_years" - 41-45_year_count - Y - - - "51+_years" - 41-45_year_count - Y - - - "all_M_W" - gender - N - - - "46-50_years" - 46-50_year_count - Y - - - "17_yaers_percent" - 17_year_percent - Y - - - "18-26_years_percent" - 18-26_year_percent - Y - - - "27-30_years_percent" - 27-30_year_percent - Y - - - "31-35_years_percent" - 31-35_year_percent - Y - - - "36-40_years_percent" - 36-40_year_percent - Y - - - "41-45_years_percent" - 41-45_year_percent - Y - - - "46-50_years_percent" - 46-50_year_percent - Y - - - "51+_years_percent" - 51+_year_percent - Y - - - recruitment_id - recruitment_id - N - - - registered - registered - N - -
- - - - - - - - - - 1056 - 1056 - Y - -
- - Select values 3 2 3 - SelectValues - - Y - - 1 - - none - - - - N - - REG_ID - REG_ID - String - -2 - -2 - - false - - - false - - - - - - - - VK_ARRAY - VK_ARRAY - String - -2 - -2 - - false - - - false - - - - - - - - - - - - - - - - - 800 - 736 - Y - - - - Select values 3 2 2 3 - SelectValues - - Y - - 1 - - none - - - - N - - REG_ID - REG_ID - String - -2 - -2 - - false - - - false - - - - - - - - VK_ARRAY - VK_ARRAY - String - -2 - -2 - - false - - - false - - - - - - - - - - - - - - - - - 800 - 896 - Y - - - - Select values 3 2 2 2 2 - SelectValues - - Y - - 1 - - none - - - - N - - REG_ID - REG_ID - String - -2 - -2 - - false - - - false - - - - - - - - VK_ARRAY - VK_ARRAY - String - -2 - -2 - - false - - - false - - - - - - - - - - - - - - - - - 800 - 1056 - Y - - - - Table input (person_registry) регион/все 2 - TableInput - - Y - - 1 - - none - - - ervu_person_registry - WITH total_count AS ( - SELECT - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) - END AS total - FROM public.recruits r - JOIN public.recruits_info ri ON ri.recruit_id = r.id - WHERE r.vu_current_info->>'isMilitaryRegistered' = 'false' - AND r.current_recruitment_id IS NOT NULL - AND ( - '${VK_ARRAY}' IS NULL - OR '${VK_ARRAY}' = '' - OR r.target_recruitment_id = ANY ( - string_to_array( - trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' - )::uuid[] - ) - ) -), -age_counts AS ( - SELECT - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) = 17) - END AS "17_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 18 AND 26) - END AS "18-26_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 27 AND 30) - END AS "27-30_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 31 AND 35) - END AS "31-35_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 36 AND 40) - END AS "36-40_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 41 AND 45) - END AS "41-45_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 46 AND 50) - END AS "46-50_year_count", - CASE - WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 - ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) >= 51) - END AS "51+_year_count" - FROM public.recruits r - JOIN public.recruits_info ri ON ri.recruit_id = r.id - WHERE r.vu_current_info->>'isMilitaryRegistered' = 'false' - AND r.current_recruitment_id IS NOT NULL - AND ( - '${VK_ARRAY}' IS NULL - OR '${VK_ARRAY}' = '' - OR r.target_recruitment_id = ANY ( - string_to_array( - trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' - )::uuid[] - ) - ) -) -SELECT - age_counts."17_year_count", - ROUND((age_counts."17_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "17_year_percent", - - age_counts."18-26_year_count", - ROUND((age_counts."18-26_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "18-26_year_percent", - - age_counts."27-30_year_count", - ROUND((age_counts."27-30_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "27-30_year_percent", - - age_counts."31-35_year_count", - ROUND((age_counts."31-35_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "31-35_year_percent", - - age_counts."36-40_year_count", - ROUND((age_counts."36-40_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "36-40_year_percent", - - age_counts."41-45_year_count", - ROUND((age_counts."41-45_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "41-45_year_percent", - - age_counts."46-50_year_count", - ROUND((age_counts."46-50_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "46-50_year_percent", - - age_counts."51+_year_count", - ROUND((age_counts."51+_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "51+_year_percent", - - '${REG_ID}' AS recruitment_id, - 'ALL' AS gender, - 'false' AS registered -FROM age_counts, total_count; - 0 - - N - Y - N - - - - - - - - - - 416 - 736 - Y - - Table input (person_registry) регион/женщины 2 TableInput @@ -2769,6 +2639,136 @@ FROM age_counts, total_count; Y + + Table input (person_registry) регион/мужчины + TableInput + + Y + + 1 + + none + + + ervu_person_registry + WITH total_count AS ( + SELECT + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) + END AS total + FROM public.recruits r + JOIN public.recruits_info ri ON ri.recruit_id = r.id + WHERE r.vu_current_info->>'isMilitaryRegistered' = 'true' + AND r.current_recruitment_id IS NOT NULL + AND r.gender = 'MALE' + AND ( + '${VK_ARRAY}' IS NULL + OR '${VK_ARRAY}' = '' + OR r.target_recruitment_id = ANY ( + string_to_array( + trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' + )::uuid[] + ) + ) +), +age_counts AS ( + SELECT + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) = 17) + END AS "17_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 18 AND 26) + END AS "18-26_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 27 AND 30) + END AS "27-30_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 31 AND 35) + END AS "31-35_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 36 AND 40) + END AS "36-40_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 41 AND 45) + END AS "41-45_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) BETWEEN 46 AND 50) + END AS "46-50_year_count", + CASE + WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 + ELSE COUNT(*) FILTER (WHERE EXTRACT(YEAR FROM AGE(birth_date)) >= 51) + END AS "51+_year_count" + FROM public.recruits r + JOIN public.recruits_info ri ON ri.recruit_id = r.id + WHERE r.vu_current_info->>'isMilitaryRegistered' = 'true' + AND r.gender = 'MALE' + AND r.current_recruitment_id IS NOT NULL + AND ( + '${VK_ARRAY}' IS NULL + OR '${VK_ARRAY}' = '' + OR r.target_recruitment_id = ANY ( + string_to_array( + trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',' + )::uuid[] + ) + ) +) +SELECT + age_counts."17_year_count", + ROUND((age_counts."17_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "17_year_percent", + + age_counts."18-26_year_count", + ROUND((age_counts."18-26_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "18-26_year_percent", + + age_counts."27-30_year_count", + ROUND((age_counts."27-30_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "27-30_year_percent", + + age_counts."31-35_year_count", + ROUND((age_counts."31-35_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "31-35_year_percent", + + age_counts."36-40_year_count", + ROUND((age_counts."36-40_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "36-40_year_percent", + + age_counts."41-45_year_count", + ROUND((age_counts."41-45_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "41-45_year_percent", + + age_counts."46-50_year_count", + ROUND((age_counts."46-50_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "46-50_year_percent", + + age_counts."51+_year_count", + ROUND((age_counts."51+_year_count" * 100.0) / NULLIF(total_count.total, 0), 2) AS "51+_year_percent", + + '${REG_ID}' AS recruitment_id, + 'M' AS gender, + 'true' AS registered +FROM age_counts, total_count; + 0 + + N + Y + N + + + + + + + + + + 432 + 352 + Y + + Table input (person_registry) регион/мужчины 2 TableInput