696 lines
22 KiB
Text
696 lines
22 KiB
Text
<pipeline>
|
||
<info>
|
||
<name>total_registered.reg_mil_cat(reg)</name>
|
||
<name_sync_with_filename>Y</name_sync_with_filename>
|
||
<description/>
|
||
<extended_description/>
|
||
<pipeline_version/>
|
||
<pipeline_type>Normal</pipeline_type>
|
||
<pipeline_status>0</pipeline_status>
|
||
<directory>/</directory>
|
||
<parameters>
|
||
</parameters>
|
||
<capture_transform_performance>N</capture_transform_performance>
|
||
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
|
||
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
|
||
<created_user>-</created_user>
|
||
<created_date>2024/08/02 11:56:22.507</created_date>
|
||
<modified_user>-</modified_user>
|
||
<modified_date>2024/08/02 11:56:22.507</modified_date>
|
||
<key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
|
||
<is_key_private>N</is_key_private>
|
||
</info>
|
||
<notepads>
|
||
</notepads>
|
||
<order>
|
||
<hop>
|
||
<from>Get variables 3</from>
|
||
<to>Select values 3</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Table input (person_registry) военком/рег</from>
|
||
<to>Get variables 3</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Get variables 3 2</from>
|
||
<to>Select values 3 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Table input (person_registry) военком 2</from>
|
||
<to>Get variables 3 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Select values 3</from>
|
||
<to>Insert / update (total_registered.reg_mil_cat)</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Select values 3 2</from>
|
||
<to>Insert / update (total_registered.reg_mil_cat) 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
</order>
|
||
<transform>
|
||
<name>Get variables 3</name>
|
||
<type>GetVariable</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<fields>
|
||
<field>
|
||
<name>REG_ID</name>
|
||
<variable/>
|
||
<type>String</type>
|
||
<format/>
|
||
<currency/>
|
||
<decimal/>
|
||
<group/>
|
||
<length>-1</length>
|
||
<precision>-1</precision>
|
||
<trim_type>none</trim_type>
|
||
</field>
|
||
<field>
|
||
<name>VK_ARRAY</name>
|
||
<variable/>
|
||
<type>String</type>
|
||
<format/>
|
||
<currency/>
|
||
<decimal/>
|
||
<group/>
|
||
<length>-1</length>
|
||
<precision>-1</precision>
|
||
<trim_type>none</trim_type>
|
||
</field>
|
||
</fields>
|
||
<attributes/>
|
||
<cluster_schema/>
|
||
<GUI>
|
||
<xloc>656</xloc>
|
||
<yloc>288</yloc>
|
||
<draw>Y</draw>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Get variables 3 2</name>
|
||
<type>GetVariable</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<fields>
|
||
<field>
|
||
<name>REG_ID</name>
|
||
<variable/>
|
||
<type>String</type>
|
||
<format/>
|
||
<currency/>
|
||
<decimal/>
|
||
<group/>
|
||
<length>-1</length>
|
||
<precision>-1</precision>
|
||
<trim_type>none</trim_type>
|
||
</field>
|
||
<field>
|
||
<name>VK_ARRAY</name>
|
||
<variable/>
|
||
<type>String</type>
|
||
<format/>
|
||
<currency/>
|
||
<decimal/>
|
||
<group/>
|
||
<length>-1</length>
|
||
<precision>-1</precision>
|
||
<trim_type>none</trim_type>
|
||
</field>
|
||
</fields>
|
||
<attributes/>
|
||
<cluster_schema/>
|
||
<GUI>
|
||
<xloc>656</xloc>
|
||
<yloc>400</yloc>
|
||
<draw>Y</draw>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Insert / update (total_registered.reg_mil_cat)</name>
|
||
<type>InsertUpdate</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<connection>ervu-dashboard</connection>
|
||
<commit>100</commit>
|
||
<update_bypassed>N</update_bypassed>
|
||
<lookup>
|
||
<schema>total_registered</schema>
|
||
<table>reg_mil_cat</table>
|
||
<key>
|
||
<name>REG_ID</name>
|
||
<field>recruitment_id</field>
|
||
<condition>=</condition>
|
||
<name2/>
|
||
</key>
|
||
<value>
|
||
<name>first_reg_17</name>
|
||
<rename>first_reg_17</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>first_reg_18</name>
|
||
<rename>first_reg_18</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>"mil_spec_W"</name>
|
||
<rename>mil_spec_w</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>recruitment_id</name>
|
||
<rename>recruitment_id</rename>
|
||
<update>N</update>
|
||
</value>
|
||
<value>
|
||
<name>returned_dep_liberty</name>
|
||
<rename>returned_dep_liberty</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>punished</name>
|
||
<rename>punished</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>received_citizenship</name>
|
||
<rename>received_citizenship</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>first_reg_17_percent</name>
|
||
<rename>first_reg_17_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>first_reg_18_percent</name>
|
||
<rename>first_reg_18_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>returned_dep_liberty_percent</name>
|
||
<rename>returned_dep_liberty_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>"mil_spec_W_percent"</name>
|
||
<rename>mil_spec_w_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>punished_percent</name>
|
||
<rename>punished_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>received_citizenship_percent</name>
|
||
<rename>received_citizenship_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>mil_reg</name>
|
||
<rename>mil_reg</rename>
|
||
<update>N</update>
|
||
</value>
|
||
</lookup>
|
||
<attributes/>
|
||
<cluster_schema/>
|
||
<GUI>
|
||
<xloc>1056</xloc>
|
||
<yloc>288</yloc>
|
||
<draw>Y</draw>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Insert / update (total_registered.reg_mil_cat) 2</name>
|
||
<type>InsertUpdate</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<connection>ervu-dashboard</connection>
|
||
<commit>100</commit>
|
||
<update_bypassed>N</update_bypassed>
|
||
<lookup>
|
||
<schema>total_registered</schema>
|
||
<table>reg_mil_cat</table>
|
||
<key>
|
||
<name>REG_ID</name>
|
||
<field>recruitment_id</field>
|
||
<condition>=</condition>
|
||
<name2/>
|
||
</key>
|
||
<value>
|
||
<name>first_reg_17</name>
|
||
<rename>first_reg_17</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>first_reg_18</name>
|
||
<rename>first_reg_18</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>"mil_spec_W"</name>
|
||
<rename>mil_spec_w</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>recruitment_id</name>
|
||
<rename>recruitment_id</rename>
|
||
<update>N</update>
|
||
</value>
|
||
<value>
|
||
<name>returned_dep_liberty</name>
|
||
<rename>returned_dep_liberty</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>punished</name>
|
||
<rename>punished</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>received_citizenship</name>
|
||
<rename>received_citizenship</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>first_reg_17_percent</name>
|
||
<rename>first_reg_17_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>first_reg_18_percent</name>
|
||
<rename>first_reg_18_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>returned_dep_liberty_percent</name>
|
||
<rename>returned_dep_liberty_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>"mil_spec_W_percent"</name>
|
||
<rename>mil_spec_w_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>punished_percent</name>
|
||
<rename>punished_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>received_citizenship_percent</name>
|
||
<rename>received_citizenship_percent</rename>
|
||
<update>Y</update>
|
||
</value>
|
||
<value>
|
||
<name>mil_reg</name>
|
||
<rename>mil_reg</rename>
|
||
<update>N</update>
|
||
</value>
|
||
</lookup>
|
||
<attributes/>
|
||
<cluster_schema/>
|
||
<GUI>
|
||
<xloc>1056</xloc>
|
||
<yloc>400</yloc>
|
||
<draw>Y</draw>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Select values 3</name>
|
||
<type>SelectValues</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<fields>
|
||
<select_unspecified>N</select_unspecified>
|
||
<meta>
|
||
<name>REG_ID</name>
|
||
<rename>REG_ID</rename>
|
||
<type>String</type>
|
||
<length>-2</length>
|
||
<precision>-2</precision>
|
||
<conversion_mask/>
|
||
<date_format_lenient>false</date_format_lenient>
|
||
<date_format_locale/>
|
||
<date_format_timezone/>
|
||
<lenient_string_to_number>false</lenient_string_to_number>
|
||
<encoding/>
|
||
<decimal_symbol/>
|
||
<grouping_symbol/>
|
||
<currency_symbol/>
|
||
<storage_type/>
|
||
</meta>
|
||
<meta>
|
||
<name>VK_ARRAY</name>
|
||
<rename>VK_ARRAY</rename>
|
||
<type>String</type>
|
||
<length>-2</length>
|
||
<precision>-2</precision>
|
||
<conversion_mask/>
|
||
<date_format_lenient>false</date_format_lenient>
|
||
<date_format_locale/>
|
||
<date_format_timezone/>
|
||
<lenient_string_to_number>false</lenient_string_to_number>
|
||
<encoding/>
|
||
<decimal_symbol/>
|
||
<grouping_symbol/>
|
||
<currency_symbol/>
|
||
<storage_type/>
|
||
</meta>
|
||
</fields>
|
||
<attributes/>
|
||
<cluster_schema/>
|
||
<GUI>
|
||
<xloc>800</xloc>
|
||
<yloc>288</yloc>
|
||
<draw>Y</draw>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Select values 3 2</name>
|
||
<type>SelectValues</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<fields>
|
||
<select_unspecified>N</select_unspecified>
|
||
<meta>
|
||
<name>REG_ID</name>
|
||
<rename>REG_ID</rename>
|
||
<type>String</type>
|
||
<length>-2</length>
|
||
<precision>-2</precision>
|
||
<conversion_mask/>
|
||
<date_format_lenient>false</date_format_lenient>
|
||
<date_format_locale/>
|
||
<date_format_timezone/>
|
||
<lenient_string_to_number>false</lenient_string_to_number>
|
||
<encoding/>
|
||
<decimal_symbol/>
|
||
<grouping_symbol/>
|
||
<currency_symbol/>
|
||
<storage_type/>
|
||
</meta>
|
||
<meta>
|
||
<name>VK_ARRAY</name>
|
||
<rename>VK_ARRAY</rename>
|
||
<type>String</type>
|
||
<length>-2</length>
|
||
<precision>-2</precision>
|
||
<conversion_mask/>
|
||
<date_format_lenient>false</date_format_lenient>
|
||
<date_format_locale/>
|
||
<date_format_timezone/>
|
||
<lenient_string_to_number>false</lenient_string_to_number>
|
||
<encoding/>
|
||
<decimal_symbol/>
|
||
<grouping_symbol/>
|
||
<currency_symbol/>
|
||
<storage_type/>
|
||
</meta>
|
||
</fields>
|
||
<attributes/>
|
||
<cluster_schema/>
|
||
<GUI>
|
||
<xloc>800</xloc>
|
||
<yloc>400</yloc>
|
||
<draw>Y</draw>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Table input (person_registry) военком 2</name>
|
||
<type>TableInput</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<connection>postgres.person_registry</connection>
|
||
<sql>WITH base_data AS (
|
||
-- Основной набор данных
|
||
SELECT
|
||
r.registration_reasons,
|
||
r.gender,
|
||
r.vu_current_info ->> 'isMilitaryRegistered' AS is_military_registered
|
||
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
|
||
WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN ARRAY[]::uuid[]
|
||
ELSE string_to_array(trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',')::uuid[]
|
||
END
|
||
)
|
||
)
|
||
),
|
||
total AS (
|
||
-- Общее количество записей
|
||
SELECT COUNT(*) AS total_count
|
||
FROM base_data
|
||
),
|
||
t1 AS (
|
||
-- Первоначальная постановка 17 лет
|
||
SELECT COUNT(*) AS first_reg_17
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"5"'
|
||
),
|
||
t2 AS (
|
||
-- Первоначальная постановка 18 лет
|
||
SELECT COUNT(*) AS first_reg_18
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"6"'
|
||
OR registration_reasons @> '"3"'
|
||
OR registration_reasons @> '"1"'
|
||
OR registration_reasons @> '"4"'
|
||
OR registration_reasons @> '"2"'
|
||
),
|
||
t3 AS (
|
||
-- Женщины, получившие ВУС
|
||
SELECT COUNT(*) AS mil_spec_w
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"3"' AND gender = 'FEMALE'
|
||
),
|
||
t4 AS (
|
||
-- Возвратившиеся из мест лишения свободы
|
||
SELECT COUNT(*) AS returned_dep_liberty
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"1"'
|
||
),
|
||
t5 AS (
|
||
-- Отбывающие наказание в местах лишения свободы
|
||
SELECT COUNT(*) AS punished
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"4"'
|
||
),
|
||
t6 AS (
|
||
-- Получившие гражданство
|
||
SELECT COUNT(*) AS received_citizenship
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"2"'
|
||
)
|
||
SELECT
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(total.total_count, 0) END AS total_count,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t1.first_reg_17, 0) END AS first_reg_17,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t2.first_reg_18, 0) END AS first_reg_18,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t3.mil_spec_w, 0) END AS mil_spec_w,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t4.returned_dep_liberty, 0) END AS returned_dep_liberty,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t5.punished, 0) END AS punished,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t6.received_citizenship, 0) END AS received_citizenship,
|
||
-- Вычисление процентов
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t1.first_reg_17 * 100.0 / NULLIF(total.total_count, 0) END, 2) AS first_reg_17_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t2.first_reg_18 * 100.0 / NULLIF(total.total_count, 0) END, 2) AS first_reg_18_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t4.returned_dep_liberty * 100.0 / NULLIF(total.total_count, 0) END, 2) AS returned_dep_liberty_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t3.mil_spec_w * 100.0 / NULLIF(total.total_count, 0) END, 2) AS mil_spec_w_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t5.punished * 100.0 / NULLIF(total.total_count, 0) END, 2) AS punished_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t6.received_citizenship * 100.0 / NULLIF(total.total_count, 0) END, 2) AS received_citizenship_percent,
|
||
'${REG_ID}' AS recruitment_id,
|
||
0 AS mil_reg,
|
||
1 AS org
|
||
FROM total
|
||
FULL OUTER JOIN t1 ON 1 = 1
|
||
FULL OUTER JOIN t2 ON 1 = 1
|
||
FULL OUTER JOIN t3 ON 1 = 1
|
||
FULL OUTER JOIN t4 ON 1 = 1
|
||
FULL OUTER JOIN t5 ON 1 = 1
|
||
FULL OUTER JOIN t6 ON 1 = 1;</sql>
|
||
<limit>0</limit>
|
||
<lookup/>
|
||
<execute_each_row>N</execute_each_row>
|
||
<variables_active>Y</variables_active>
|
||
<lazy_conversion_active>N</lazy_conversion_active>
|
||
<attributes/>
|
||
<cluster_schema/>
|
||
<GUI>
|
||
<xloc>400</xloc>
|
||
<yloc>400</yloc>
|
||
<draw>Y</draw>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Table input (person_registry) военком/рег</name>
|
||
<type>TableInput</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<connection>postgres.person_registry</connection>
|
||
<sql>WITH base_data AS (
|
||
-- Основной набор данных
|
||
SELECT
|
||
r.registration_reasons,
|
||
r.gender,
|
||
r.vu_current_info ->> 'isMilitaryRegistered' AS is_military_registered
|
||
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
|
||
WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN ARRAY[]::uuid[]
|
||
ELSE string_to_array(trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ',')::uuid[]
|
||
END
|
||
)
|
||
)
|
||
),
|
||
total AS (
|
||
-- Общее количество записей
|
||
SELECT COUNT(*) AS total_count
|
||
FROM base_data
|
||
),
|
||
t1 AS (
|
||
-- Первоначальная постановка 17 лет
|
||
SELECT COUNT(*) AS first_reg_17
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"5"'
|
||
),
|
||
t2 AS (
|
||
-- Первоначальная постановка 18 лет
|
||
SELECT COUNT(*) AS first_reg_18
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"6"'
|
||
OR registration_reasons @> '"3"'
|
||
OR registration_reasons @> '"1"'
|
||
OR registration_reasons @> '"4"'
|
||
OR registration_reasons @> '"2"'
|
||
),
|
||
t3 AS (
|
||
-- Женщины, получившие ВУС
|
||
SELECT COUNT(*) AS mil_spec_w
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"3"' AND gender = 'FEMALE'
|
||
),
|
||
t4 AS (
|
||
-- Возвратившиеся из мест лишения свободы
|
||
SELECT COUNT(*) AS returned_dep_liberty
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"1"'
|
||
),
|
||
t5 AS (
|
||
-- Отбывающие наказание в местах лишения свободы
|
||
SELECT COUNT(*) AS punished
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"4"'
|
||
),
|
||
t6 AS (
|
||
-- Получившие гражданство
|
||
SELECT COUNT(*) AS received_citizenship
|
||
FROM base_data
|
||
WHERE registration_reasons @> '"2"'
|
||
)
|
||
SELECT
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(total.total_count, 0) END AS total_count,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t1.first_reg_17, 0) END AS first_reg_17,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t2.first_reg_18, 0) END AS first_reg_18,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t3.mil_spec_w, 0) END AS mil_spec_w,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t4.returned_dep_liberty, 0) END AS returned_dep_liberty,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t5.punished, 0) END AS punished,
|
||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE COALESCE(t6.received_citizenship, 0) END AS received_citizenship,
|
||
-- Вычисление процентов
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t1.first_reg_17 * 100.0 / NULLIF(total.total_count, 0) END, 2) AS first_reg_17_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t2.first_reg_18 * 100.0 / NULLIF(total.total_count, 0) END, 2) AS first_reg_18_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t4.returned_dep_liberty * 100.0 / NULLIF(total.total_count, 0) END, 2) AS returned_dep_liberty_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t3.mil_spec_w * 100.0 / NULLIF(total.total_count, 0) END, 2) AS mil_spec_w_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t5.punished * 100.0 / NULLIF(total.total_count, 0) END, 2) AS punished_percent,
|
||
ROUND(CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t6.received_citizenship * 100.0 / NULLIF(total.total_count, 0) END, 2) AS received_citizenship_percent,
|
||
'${REG_ID}' AS recruitment_id,
|
||
1 AS mil_reg,
|
||
1 AS org
|
||
FROM total
|
||
FULL OUTER JOIN t1 ON 1 = 1
|
||
FULL OUTER JOIN t2 ON 1 = 1
|
||
FULL OUTER JOIN t3 ON 1 = 1
|
||
FULL OUTER JOIN t4 ON 1 = 1
|
||
FULL OUTER JOIN t5 ON 1 = 1
|
||
FULL OUTER JOIN t6 ON 1 = 1;</sql>
|
||
<limit>0</limit>
|
||
<lookup/>
|
||
<execute_each_row>N</execute_each_row>
|
||
<variables_active>Y</variables_active>
|
||
<lazy_conversion_active>N</lazy_conversion_active>
|
||
<attributes/>
|
||
<cluster_schema/>
|
||
<GUI>
|
||
<xloc>400</xloc>
|
||
<yloc>288</yloc>
|
||
<draw>Y</draw>
|
||
</GUI>
|
||
</transform>
|
||
<transform_error_handling>
|
||
</transform_error_handling>
|
||
<attributes/>
|
||
</pipeline>
|