919 lines
28 KiB
XML
919 lines
28 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<pipeline>
|
|
<info>
|
|
<name>total_registered.child_minor</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>
|
|
<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>
|
|
</info>
|
|
<notepads>
|
|
</notepads>
|
|
<order>
|
|
<hop>
|
|
<from>Table input (person_registry)РФ/женщины</from>
|
|
<to>Insert / update (total_registered.child_minor) 3</to>
|
|
<enabled>N</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Table input (person_registry)РФ/мужчины</from>
|
|
<to>Insert / update (total_registered.child_minor) 2</to>
|
|
<enabled>N</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Table input (person_registry)РФ/все</from>
|
|
<to>Insert / update (total_registered.child_minor)</to>
|
|
<enabled>N</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Get variables 2 2</from>
|
|
<to>Select values 2 2</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Get variables 2 2 2</from>
|
|
<to>Select values 2 2 2</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Get variables 2 2 3</from>
|
|
<to>Select values 2 2 3</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Table input (person_registry)РФ/все</from>
|
|
<to>Get variables 2 2</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Select values 2 2</from>
|
|
<to>Insert / update (total_registered.child_minor)</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Table input (person_registry)РФ/мужчины</from>
|
|
<to>Get variables 2 2 2</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Select values 2 2 2</from>
|
|
<to>Insert / update (total_registered.child_minor) 2</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Table input (person_registry)РФ/женщины</from>
|
|
<to>Get variables 2 2 3</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
<hop>
|
|
<from>Select values 2 2 3</from>
|
|
<to>Insert / update (total_registered.child_minor) 3</to>
|
|
<enabled>Y</enabled>
|
|
</hop>
|
|
</order>
|
|
<transform>
|
|
<name>Insert / update (total_registered.child_minor)</name>
|
|
<type>InsertUpdate</type>
|
|
<description/>
|
|
<distribute>Y</distribute>
|
|
<custom_distribution/>
|
|
<copies>1</copies>
|
|
<partitioning>
|
|
<method>none</method>
|
|
<schema_name/>
|
|
</partitioning>
|
|
<commit>100</commit>
|
|
<connection>ervu-dashboard</connection>
|
|
<lookup>
|
|
<key>
|
|
<condition>=</condition>
|
|
<field>recruitment_id</field>
|
|
<name>REG_ID</name>
|
|
<name2/>
|
|
</key>
|
|
<key>
|
|
<condition>=</condition>
|
|
<field>"all_M_W"</field>
|
|
<name>gender</name>
|
|
<name2/>
|
|
</key>
|
|
<schema>total_registered</schema>
|
|
<table>child_minor</table>
|
|
<value>
|
|
<name>no_child</name>
|
|
<rename>no_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"1_child"</name>
|
|
<rename>one_child</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"2_child"</name>
|
|
<rename>two_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"3_child"</name>
|
|
<rename>three_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"4_more_child"</name>
|
|
<rename>four_or_more_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"all_M_W"</name>
|
|
<rename>gender</rename>
|
|
<update>N</update>
|
|
</value>
|
|
<value>
|
|
<name>no_child_percent</name>
|
|
<rename>no_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"1_child_percent"</name>
|
|
<rename>one_child_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"2_child_percent"</name>
|
|
<rename>two_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"3_child_percent"</name>
|
|
<rename>three_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"4_more_child_percent"</name>
|
|
<rename>four_or_more_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>recruitment_id</name>
|
|
<rename>recruitment_id</rename>
|
|
<update>N</update>
|
|
</value>
|
|
</lookup>
|
|
<update_bypassed>N</update_bypassed>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>992</xloc>
|
|
<yloc>240</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform>
|
|
<name>Insert / update (total_registered.child_minor) 2</name>
|
|
<type>InsertUpdate</type>
|
|
<description/>
|
|
<distribute>Y</distribute>
|
|
<custom_distribution/>
|
|
<copies>1</copies>
|
|
<partitioning>
|
|
<method>none</method>
|
|
<schema_name/>
|
|
</partitioning>
|
|
<commit>100</commit>
|
|
<connection>ervu-dashboard</connection>
|
|
<lookup>
|
|
<key>
|
|
<condition>=</condition>
|
|
<field>recruitment_id</field>
|
|
<name>REG_ID</name>
|
|
<name2/>
|
|
</key>
|
|
<key>
|
|
<condition>=</condition>
|
|
<field>"all_M_W"</field>
|
|
<name>gender</name>
|
|
<name2/>
|
|
</key>
|
|
<schema>total_registered</schema>
|
|
<table>child_minor</table>
|
|
<value>
|
|
<name>no_child</name>
|
|
<rename>no_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"1_child"</name>
|
|
<rename>one_child</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"2_child"</name>
|
|
<rename>two_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"3_child"</name>
|
|
<rename>three_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"4_more_child"</name>
|
|
<rename>four_or_more_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"all_M_W"</name>
|
|
<rename>gender</rename>
|
|
<update>N</update>
|
|
</value>
|
|
<value>
|
|
<name>no_child_percent</name>
|
|
<rename>no_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"1_child_percent"</name>
|
|
<rename>one_child_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"2_child_percent"</name>
|
|
<rename>two_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"3_child_percent"</name>
|
|
<rename>three_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"4_more_child_percent"</name>
|
|
<rename>four_or_more_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>recruitment_id</name>
|
|
<rename>recruitment_id</rename>
|
|
<update>N</update>
|
|
</value>
|
|
</lookup>
|
|
<update_bypassed>N</update_bypassed>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>992</xloc>
|
|
<yloc>336</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform>
|
|
<name>Insert / update (total_registered.child_minor) 3</name>
|
|
<type>InsertUpdate</type>
|
|
<description/>
|
|
<distribute>Y</distribute>
|
|
<custom_distribution/>
|
|
<copies>1</copies>
|
|
<partitioning>
|
|
<method>none</method>
|
|
<schema_name/>
|
|
</partitioning>
|
|
<commit>100</commit>
|
|
<connection>ervu-dashboard</connection>
|
|
<lookup>
|
|
<key>
|
|
<condition>=</condition>
|
|
<field>recruitment_id</field>
|
|
<name>REG_ID</name>
|
|
<name2/>
|
|
</key>
|
|
<key>
|
|
<condition>=</condition>
|
|
<field>"all_M_W"</field>
|
|
<name>gender</name>
|
|
<name2/>
|
|
</key>
|
|
<schema>total_registered</schema>
|
|
<table>child_minor</table>
|
|
<value>
|
|
<name>no_child</name>
|
|
<rename>no_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"1_child"</name>
|
|
<rename>one_child</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"2_child"</name>
|
|
<rename>two_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"3_child"</name>
|
|
<rename>three_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"4_more_child"</name>
|
|
<rename>four_or_more_children</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"all_M_W"</name>
|
|
<rename>gender</rename>
|
|
<update>N</update>
|
|
</value>
|
|
<value>
|
|
<name>no_child_percent</name>
|
|
<rename>no_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"1_child_percent"</name>
|
|
<rename>one_child_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"2_child_percent"</name>
|
|
<rename>two_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"3_child_percent"</name>
|
|
<rename>three_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>"4_more_child_percent"</name>
|
|
<rename>four_or_more_children_percent</rename>
|
|
<update>Y</update>
|
|
</value>
|
|
<value>
|
|
<name>recruitment_id</name>
|
|
<rename>recruitment_id</rename>
|
|
<update>N</update>
|
|
</value>
|
|
</lookup>
|
|
<update_bypassed>N</update_bypassed>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>992</xloc>
|
|
<yloc>448</yloc>
|
|
</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>ervu_person_registry</connection>
|
|
<execute_each_row>N</execute_each_row>
|
|
<limit>0</limit>
|
|
<sql>WITH extracted_children AS (
|
|
SELECT
|
|
ri.recruit_id,
|
|
jsonb_array_elements_text(ri.info->'svedDeti'->'rebenok') AS child
|
|
FROM
|
|
public.recruits_info ri
|
|
JOIN public.recruits r 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 r.target_recruitment_id is not null
|
|
),
|
|
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_18
|
|
FROM
|
|
children_birth_dates
|
|
WHERE
|
|
AGE(make_date(year, month, day)) < interval '18 years'
|
|
GROUP BY
|
|
recruit_id
|
|
),
|
|
final_counts AS (
|
|
SELECT
|
|
COALESCE(children_under_18, 0) AS children_count,
|
|
COUNT(*) AS num_people
|
|
FROM
|
|
public.recruits_info ri
|
|
LEFT JOIN
|
|
children_count cc ON ri.recruit_id = cc.recruit_id
|
|
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
|
|
GROUP BY
|
|
COALESCE(children_under_18, 0)
|
|
),
|
|
total_people AS (
|
|
SELECT SUM(num_people) AS total_count
|
|
FROM final_counts
|
|
)
|
|
SELECT
|
|
'ALL' AS gender,
|
|
'${REG_ID}' as recruitment_id,
|
|
COALESCE(SUM(CASE WHEN children_count = 0 THEN num_people ELSE 0 END), 0) AS no_children,
|
|
COALESCE(SUM(CASE WHEN children_count = 1 THEN num_people ELSE 0 END), 0) AS one_child,
|
|
COALESCE(SUM(CASE WHEN children_count = 2 THEN num_people ELSE 0 END), 0) AS two_children,
|
|
COALESCE(SUM(CASE WHEN children_count = 3 THEN num_people ELSE 0 END), 0) AS three_children,
|
|
COALESCE(SUM(CASE WHEN children_count >= 4 THEN num_people ELSE 0 END), 0) AS four_or_more_children,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 0 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_count FROM total_people), 0), 2) AS no_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 1 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_count FROM total_people), 0), 2) AS one_child_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 2 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_count FROM total_people), 0), 2) AS two_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 3 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_count FROM total_people), 0), 2) AS three_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count >= 4 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_count FROM total_people), 0), 2) AS four_or_more_children_percent
|
|
FROM
|
|
final_counts;</sql>
|
|
<variables_active>Y</variables_active>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>352</xloc>
|
|
<yloc>240</yloc>
|
|
</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>ervu_person_registry</connection>
|
|
<execute_each_row>N</execute_each_row>
|
|
<limit>0</limit>
|
|
<sql>WITH extracted_children AS (
|
|
SELECT
|
|
ri.recruit_id,
|
|
jsonb_array_elements_text(ri.info->'svedDeti'->'rebenok') AS child
|
|
FROM
|
|
public.recruits_info ri
|
|
JOIN public.recruits r 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 r.target_recruitment_id IS NOT NULL
|
|
AND r.gender = 'FEMALE'
|
|
),
|
|
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_18
|
|
FROM
|
|
children_birth_dates
|
|
WHERE
|
|
make_date(year, month, day) > CURRENT_DATE - INTERVAL '18 years'
|
|
GROUP BY
|
|
recruit_id
|
|
),
|
|
final_counts AS (
|
|
SELECT
|
|
COALESCE(children_under_18, 0) AS children_count,
|
|
COUNT(*) AS num_people
|
|
FROM
|
|
public.recruits_info ri
|
|
LEFT JOIN
|
|
children_count cc ON ri.recruit_id = cc.recruit_id
|
|
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
|
|
AND r.gender = 'FEMALE'
|
|
GROUP BY
|
|
COALESCE(children_under_18, 0)
|
|
),
|
|
total_men AS (
|
|
SELECT
|
|
COUNT(*) AS total_men_count
|
|
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
|
|
AND r.gender = 'FEMALE'
|
|
)
|
|
SELECT
|
|
'W' AS gender,
|
|
'${REG_ID}' AS recruitment_id,
|
|
COALESCE(SUM(CASE WHEN children_count = 0 THEN num_people ELSE 0 END), 0) AS no_children,
|
|
COALESCE(SUM(CASE WHEN children_count = 1 THEN num_people ELSE 0 END), 0) AS one_child,
|
|
COALESCE(SUM(CASE WHEN children_count = 2 THEN num_people ELSE 0 END), 0) AS two_children,
|
|
COALESCE(SUM(CASE WHEN children_count = 3 THEN num_people ELSE 0 END), 0) AS three_children,
|
|
COALESCE(SUM(CASE WHEN children_count >= 4 THEN num_people ELSE 0 END), 0) AS four_or_more_children,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 0 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS no_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 1 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS one_child_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 2 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS two_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 3 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS three_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count >= 4 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS four_or_more_children_percent
|
|
FROM
|
|
final_counts;</sql>
|
|
<variables_active>Y</variables_active>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>352</xloc>
|
|
<yloc>448</yloc>
|
|
</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>ervu_person_registry</connection>
|
|
<execute_each_row>N</execute_each_row>
|
|
<limit>0</limit>
|
|
<sql>WITH extracted_children AS (
|
|
SELECT
|
|
ri.recruit_id,
|
|
jsonb_array_elements_text(ri.info->'svedDeti'->'rebenok') AS child
|
|
FROM
|
|
public.recruits_info ri
|
|
JOIN public.recruits r 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 r.target_recruitment_id IS NOT NULL
|
|
AND r.gender = 'MALE'
|
|
),
|
|
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_18
|
|
FROM
|
|
children_birth_dates
|
|
WHERE
|
|
make_date(year, month, day) > CURRENT_DATE - INTERVAL '18 years'
|
|
GROUP BY
|
|
recruit_id
|
|
),
|
|
final_counts AS (
|
|
SELECT
|
|
COALESCE(children_under_18, 0) AS children_count,
|
|
COUNT(*) AS num_people
|
|
FROM
|
|
public.recruits_info ri
|
|
LEFT JOIN
|
|
children_count cc ON ri.recruit_id = cc.recruit_id
|
|
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
|
|
AND r.gender = 'MALE'
|
|
GROUP BY
|
|
COALESCE(children_under_18, 0)
|
|
),
|
|
total_men AS (
|
|
SELECT
|
|
COUNT(*) AS total_men_count
|
|
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
|
|
AND r.gender = 'MALE'
|
|
)
|
|
SELECT
|
|
'M' AS gender,
|
|
'${REG_ID}' AS recruitment_id,
|
|
COALESCE(SUM(CASE WHEN children_count = 0 THEN num_people ELSE 0 END), 0) AS no_children,
|
|
COALESCE(SUM(CASE WHEN children_count = 1 THEN num_people ELSE 0 END), 0) AS one_child,
|
|
COALESCE(SUM(CASE WHEN children_count = 2 THEN num_people ELSE 0 END), 0) AS two_children,
|
|
COALESCE(SUM(CASE WHEN children_count = 3 THEN num_people ELSE 0 END), 0) AS three_children,
|
|
COALESCE(SUM(CASE WHEN children_count >= 4 THEN num_people ELSE 0 END), 0) AS four_or_more_children,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 0 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS no_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 1 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS one_child_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 2 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS two_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count = 3 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS three_children_percent,
|
|
ROUND(COALESCE(SUM(CASE WHEN children_count >= 4 THEN num_people ELSE 0 END), 0) * 100.0 / NULLIF((SELECT total_men_count FROM total_men), 0), 2) AS four_or_more_children_percent
|
|
FROM
|
|
final_counts;</sql>
|
|
<variables_active>Y</variables_active>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>352</xloc>
|
|
<yloc>336</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform>
|
|
<name>Get variables 2 2</name>
|
|
<type>GetVariable</type>
|
|
<description/>
|
|
<distribute>Y</distribute>
|
|
<custom_distribution/>
|
|
<copies>1</copies>
|
|
<partitioning>
|
|
<method>none</method>
|
|
<schema_name/>
|
|
</partitioning>
|
|
<fields>
|
|
<field>
|
|
<length>-1</length>
|
|
<name>REG_ID</name>
|
|
<precision>-1</precision>
|
|
<trim_type>none</trim_type>
|
|
<type>String</type>
|
|
</field>
|
|
<field>
|
|
<length>-1</length>
|
|
<name>VK_ARRAY</name>
|
|
<precision>-1</precision>
|
|
<trim_type>none</trim_type>
|
|
<type>String</type>
|
|
</field>
|
|
</fields>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>560</xloc>
|
|
<yloc>272</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform>
|
|
<name>Select values 2 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/>
|
|
<GUI>
|
|
<xloc>768</xloc>
|
|
<yloc>272</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform>
|
|
<name>Get variables 2 2 2</name>
|
|
<type>GetVariable</type>
|
|
<description/>
|
|
<distribute>Y</distribute>
|
|
<custom_distribution/>
|
|
<copies>1</copies>
|
|
<partitioning>
|
|
<method>none</method>
|
|
<schema_name/>
|
|
</partitioning>
|
|
<fields>
|
|
<field>
|
|
<length>-1</length>
|
|
<name>REG_ID</name>
|
|
<precision>-1</precision>
|
|
<trim_type>none</trim_type>
|
|
<type>String</type>
|
|
</field>
|
|
<field>
|
|
<length>-1</length>
|
|
<name>VK_ARRAY</name>
|
|
<precision>-1</precision>
|
|
<trim_type>none</trim_type>
|
|
<type>String</type>
|
|
</field>
|
|
</fields>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>560</xloc>
|
|
<yloc>368</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform>
|
|
<name>Select values 2 2 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/>
|
|
<GUI>
|
|
<xloc>768</xloc>
|
|
<yloc>368</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform>
|
|
<name>Get variables 2 2 3</name>
|
|
<type>GetVariable</type>
|
|
<description/>
|
|
<distribute>Y</distribute>
|
|
<custom_distribution/>
|
|
<copies>1</copies>
|
|
<partitioning>
|
|
<method>none</method>
|
|
<schema_name/>
|
|
</partitioning>
|
|
<fields>
|
|
<field>
|
|
<length>-1</length>
|
|
<name>REG_ID</name>
|
|
<precision>-1</precision>
|
|
<trim_type>none</trim_type>
|
|
<type>String</type>
|
|
</field>
|
|
<field>
|
|
<length>-1</length>
|
|
<name>VK_ARRAY</name>
|
|
<precision>-1</precision>
|
|
<trim_type>none</trim_type>
|
|
<type>String</type>
|
|
</field>
|
|
</fields>
|
|
<attributes/>
|
|
<GUI>
|
|
<xloc>560</xloc>
|
|
<yloc>496</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform>
|
|
<name>Select values 2 2 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/>
|
|
<GUI>
|
|
<xloc>768</xloc>
|
|
<yloc>496</yloc>
|
|
</GUI>
|
|
</transform>
|
|
<transform_error_handling>
|
|
</transform_error_handling>
|
|
<attributes/>
|
|
</pipeline>
|