ervu-dashboard-etl/mappings/region/recruitment_campaign.subpoenas(reg).hpl

898 lines
27 KiB
Text

<pipeline>
<info>
<name>recruitment_campaign.subpoenas(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/09 13:13:59.825</created_date>
<modified_user>-</modified_user>
<modified_date>2024/08/09 13:13:59.825</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 4 3</from>
<to>Select values 4 3</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input (subpoena) осень/регионы</from>
<to>Get variables 4 3</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Get variables 4 3 2</from>
<to>Select values 4 3 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input (subpoena) весна/регионы</from>
<to>Get variables 4 3 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Select values 4 3</from>
<to>Insert / update (recruitment_campaign.subpoenas) 3</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Select values 4 3 2</from>
<to>Insert / update (recruitment_campaign.subpoenas) 3 2</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Get variables 4 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>416</xloc>
<yloc>400</yloc>
<draw>Y</draw>
</GUI>
</transform>
<transform>
<name>Get variables 4 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>416</xloc>
<yloc>480</yloc>
<draw>Y</draw>
</GUI>
</transform>
<transform>
<name>Insert / update (recruitment_campaign.subpoenas) 3</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>recruitment_campaign</schema>
<table>subpoenas</table>
<key>
<name>REG_ID</name>
<field>recruitment_id</field>
<condition>=</condition>
<name2/>
</key>
<value>
<name>subpoena</name>
<rename>count_subpoena</rename>
<update>Y</update>
</value>
<value>
<name>appeared</name>
<rename>count_appeared</rename>
<update>Y</update>
</value>
<value>
<name>not_appeared</name>
<rename>count_not_appeared</rename>
<update>Y</update>
</value>
<value>
<name>not_ap_good_reason</name>
<rename>count_not_ap_good_reason</rename>
<update>Y</update>
</value>
<value>
<name>introduced_measures</name>
<rename>count_introduced_measures</rename>
<update>Y</update>
</value>
<value>
<name>ap_not_required</name>
<rename>count_ap_not_required</rename>
<update>Y</update>
</value>
<value>
<name>restrictions_applied</name>
<rename>count_restrictions_applied</rename>
<update>Y</update>
</value>
<value>
<name>appeared_percent</name>
<rename>appeared_percent</rename>
<update>Y</update>
</value>
<value>
<name>not_appeared_percent</name>
<rename>not_appeared_percent</rename>
<update>Y</update>
</value>
<value>
<name>not_ap_good_reason_percent</name>
<rename>not_ap_good_reason_percent</rename>
<update>Y</update>
</value>
<value>
<name>ap_not_required_percent</name>
<rename>ap_not_required_percent</rename>
<update>Y</update>
</value>
<value>
<name>restrictions_applied_percent</name>
<rename>restrictions_applied_percent</rename>
<update>Y</update>
</value>
<value>
<name>introduced_measures_percent</name>
<rename>introduced_measures_percent</rename>
<update>Y</update>
</value>
<value>
<name>recruitment_id</name>
<rename>recruitment_id</rename>
<update>N</update>
</value>
<value>
<name>rest</name>
<rename>rest</rename>
<update>Y</update>
</value>
<value>
<name>spring_autumn</name>
<rename>spring_autumn</rename>
<update>N</update>
</value>
<value>
<name>count_not_delivery</name>
<rename>count_not_delivery</rename>
<update>Y</update>
</value>
<value>
<name>appear_date_is_good</name>
<rename>appear_date_is_good</rename>
<update>Y</update>
</value>
<value>
<name>not_delivery_percent</name>
<rename>not_delivery_percent</rename>
<update>Y</update>
</value>
<value>
<name>appear_date_is_good_percent</name>
<rename>appear_date_is_good_percent</rename>
<update>Y</update>
</value>
</lookup>
<attributes/>
<cluster_schema/>
<GUI>
<xloc>896</xloc>
<yloc>400</yloc>
<draw>Y</draw>
</GUI>
</transform>
<transform>
<name>Insert / update (recruitment_campaign.subpoenas) 3 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>recruitment_campaign</schema>
<table>subpoenas</table>
<key>
<name>REG_ID</name>
<field>recruitment_id</field>
<condition>=</condition>
<name2/>
</key>
<value>
<name>subpoena</name>
<rename>count_subpoena</rename>
<update>Y</update>
</value>
<value>
<name>appeared</name>
<rename>count_appeared</rename>
<update>Y</update>
</value>
<value>
<name>not_appeared</name>
<rename>count_not_appeared</rename>
<update>Y</update>
</value>
<value>
<name>not_ap_good_reason</name>
<rename>count_not_ap_good_reason</rename>
<update>Y</update>
</value>
<value>
<name>introduced_measures</name>
<rename>count_introduced_measures</rename>
<update>Y</update>
</value>
<value>
<name>ap_not_required</name>
<rename>count_ap_not_required</rename>
<update>Y</update>
</value>
<value>
<name>restrictions_applied</name>
<rename>count_restrictions_applied</rename>
<update>Y</update>
</value>
<value>
<name>appeared_percent</name>
<rename>appeared_percent</rename>
<update>Y</update>
</value>
<value>
<name>not_appeared_percent</name>
<rename>not_appeared_percent</rename>
<update>Y</update>
</value>
<value>
<name>not_ap_good_reason_percent</name>
<rename>not_ap_good_reason_percent</rename>
<update>Y</update>
</value>
<value>
<name>ap_not_required_percent</name>
<rename>ap_not_required_percent</rename>
<update>Y</update>
</value>
<value>
<name>restrictions_applied_percent</name>
<rename>restrictions_applied_percent</rename>
<update>Y</update>
</value>
<value>
<name>introduced_measures_percent</name>
<rename>introduced_measures_percent</rename>
<update>Y</update>
</value>
<value>
<name>recruitment_id</name>
<rename>recruitment_id</rename>
<update>N</update>
</value>
<value>
<name>rest</name>
<rename>rest</rename>
<update>Y</update>
</value>
<value>
<name>spring_autumn</name>
<rename>spring_autumn</rename>
<update>N</update>
</value>
<value>
<name>count_not_delivery</name>
<rename>count_not_delivery</rename>
<update>Y</update>
</value>
<value>
<name>appear_date_is_good</name>
<rename>appear_date_is_good</rename>
<update>Y</update>
</value>
<value>
<name>not_delivery_percent</name>
<rename>not_delivery_percent</rename>
<update>Y</update>
</value>
<value>
<name>appear_date_is_good_percent</name>
<rename>appear_date_is_good_percent</rename>
<update>Y</update>
</value>
</lookup>
<attributes/>
<cluster_schema/>
<GUI>
<xloc>896</xloc>
<yloc>480</yloc>
<draw>Y</draw>
</GUI>
</transform>
<transform>
<name>Select values 4 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>592</xloc>
<yloc>400</yloc>
<draw>Y</draw>
</GUI>
</transform>
<transform>
<name>Select values 4 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>592</xloc>
<yloc>480</yloc>
<draw>Y</draw>
</GUI>
</transform>
<transform>
<name>Table input (subpoena) весна/регионы</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<connection>postgres.subpoena</connection>
<sql>WITH subpoena_data AS (
SELECT
s.id AS subpoena_id,
s.status_id,
sr.type,
ssh.code AS sub_stat_hist,
s.send_date,
sh.date_time::timestamp AS history_date,
rdi.restriction_document_cancel_id AS restr_dc,
rdi.applied_date AS ap_date,
rdi.id AS rdi_id,
ssi.delivery_code AS d_code,
ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY sh.date_time DESC) AS rn
FROM subpoena s
JOIN subpoena_history AS sh ON sh.subpoena_id = s.id
JOIN subpoena_status AS ss ON ss.id = s.status_id
JOIN subpoena_status AS ssh ON ssh.id = sh.status_id
JOIN subpoena_reason AS sr ON sr.id = s.reason_id
LEFT JOIN restriction_document AS rd ON rd.subpoena_id = s.id
LEFT JOIN restriction_document_item AS rdi ON rdi.restriction_document_create_id = rd.id
LEFT JOIN subpoena_send_info AS ssi ON ssi.subpoena_id = s.id
WHERE sr.type = '3'
AND ssh.code NOT IN ('3.14','3.7','3.72', '3.71')
AND (
COALESCE('${VK_ARRAY}', '') = ''
OR s.department_id = ANY (
string_to_array(
trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')),
','
)::uuid[]
)
)
),
last_status AS (
SELECT *
FROM subpoena_data
WHERE rn = 1
),
t1 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_subpoena
FROM last_status
WHERE sub_stat_hist IS NOT NULL
),
t2 AS (
SELECT ROUND(AVG(EXTRACT(DAY FROM (history_date::timestamp - send_date::timestamp))), 1) AS average_appeared
FROM last_status
WHERE sub_stat_hist IN ('4.1', '4.2', '4')
),
t3 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_appeared
FROM last_status
WHERE sub_stat_hist IN ('4.1', '4.2', '4')
),
t4 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_not_appeared
FROM last_status
WHERE sub_stat_hist = '5'
),
t5 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_not_ap_good_reason
FROM last_status
WHERE sub_stat_hist = '5.1'
),
t6 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_ap_not_required
FROM last_status
WHERE sub_stat_hist IN ('3.8', '5.2')
),
t7 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_restrictions_applied
FROM last_status
WHERE restr_dc IS NULL
),
t8 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_introduced_measures
FROM last_status
WHERE restr_dc IS NULL AND ap_date IS NOT NULL
),
t9 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_paper
FROM last_status
WHERE d_code != '7'
),
t10 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_electron
FROM last_status
WHERE d_code = '7'
),
t11 AS (
SELECT COUNT (DISTINCT rdi_id) AS count_restrictions
FROM last_status
),
t12 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_not_delivery
FROM last_status
WHERE d_code IS NULL
),
t13 AS (
SELECT COUNT(DISTINCT subpoena_id) AS appear_date_is_good
FROM last_status
WHERE sub_stat_hist IN ('3','3.12', '3.13', '3.15', '3.1')
)
SELECT
COALESCE(t1.count_subpoena, 0) AS count_subpoena,
COALESCE(t2.average_appeared, 0) AS average_appeared,
COALESCE(t3.count_appeared, 0) AS count_appeared,
COALESCE(t4.count_not_appeared, 0) AS count_not_appeared,
COALESCE(t5.count_not_ap_good_reason, 0) AS count_not_ap_good_reason,
COALESCE(t6.count_ap_not_required, 0) AS count_ap_not_required,
COALESCE(t7.count_restrictions_applied, 0) AS count_restrictions_applied,
COALESCE(t8.count_introduced_measures, 0) AS count_introduced_measures,
COALESCE(t9.count_paper, 0) AS count_paper,
COALESCE(t10.count_electron, 0) AS count_electron,
COALESCE(t11.count_restrictions, 0) AS count_restrictions,
COALESCE(t12.count_not_delivery, 0) AS count_not_delivery,
COALESCE(t13.appear_date_is_good, 0) AS appear_date_is_good,
ROUND(COALESCE(t3.count_appeared, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS appeared_percent,
ROUND(COALESCE(t4.count_not_appeared, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS not_appeared_percent,
ROUND(COALESCE(t5.count_not_ap_good_reason, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS not_ap_good_reason_percent,
ROUND(COALESCE(t6.count_ap_not_required, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS ap_not_required_percent,
ROUND(COALESCE(t10.count_electron, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS electron_percent,
ROUND(COALESCE(t9.count_paper, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS paper_percent,
ROUND(COALESCE(t7.count_restrictions_applied, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS restrictions_applied_percent,
ROUND(COALESCE(t8.count_introduced_measures, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS introduced_measures_percent,
ROUND(COALESCE(t12.count_not_delivery, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS not_delivery_percent,
ROUND(COALESCE(t13.appear_date_is_good, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS appear_date_is_good_percent,
'${REG_ID}' AS recruitment_id,
1 AS org,
0 AS rest,
'Весна' AS spring_autumn
FROM t1
FULL OUTER JOIN t2 ON true
FULL OUTER JOIN t3 ON true
FULL OUTER JOIN t4 ON true
FULL OUTER JOIN t5 ON true
FULL OUTER JOIN t6 ON true
FULL OUTER JOIN t7 ON true
FULL OUTER JOIN t8 ON true
FULL OUTER JOIN t9 ON true
FULL OUTER JOIN t10 ON true
FULL OUTER JOIN t11 ON true
FULL OUTER JOIN t12 ON true
FULL OUTER JOIN t13 ON true
WHERE NOT (
COALESCE('${VK_ARRAY}', '') = ''
AND (
COALESCE(t1.count_subpoena, 0) > 0
OR COALESCE(t2.average_appeared, 0) > 0
OR COALESCE(t3.count_appeared, 0) > 0
OR COALESCE(t4.count_not_appeared, 0) > 0
OR COALESCE(t5.count_not_ap_good_reason, 0) > 0
OR COALESCE(t6.count_ap_not_required, 0) > 0
OR COALESCE(t7.count_restrictions_applied, 0) > 0
OR COALESCE(t8.count_introduced_measures, 0) > 0
OR COALESCE(t9.count_paper, 0) > 0
OR COALESCE(t10.count_electron, 0) > 0
OR COALESCE(t11.count_restrictions, 0) > 0
OR COALESCE(t12.count_not_delivery, 0) > 0
OR COALESCE(t13.appear_date_is_good, 0) > 0
)
);</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>160</xloc>
<yloc>480</yloc>
<draw>Y</draw>
</GUI>
</transform>
<transform>
<name>Table input (subpoena) осень/регионы</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<connection>postgres.subpoena</connection>
<sql>WITH subpoena_data AS (
SELECT
s.id AS subpoena_id,
s.status_id,
sr.type,
ssh.code AS sub_stat_hist,
s.send_date,
sh.date_time::timestamp AS history_date,
rdi.restriction_document_cancel_id AS restr_dc,
rdi.applied_date AS ap_date,
rdi.id AS rdi_id,
ssi.delivery_code AS d_code,
ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY sh.date_time DESC) AS rn
FROM subpoena s
JOIN subpoena_history AS sh ON sh.subpoena_id = s.id
JOIN subpoena_status AS ss ON ss.id = s.status_id
JOIN subpoena_status AS ssh ON ssh.id = sh.status_id
JOIN subpoena_reason AS sr ON sr.id = s.reason_id
LEFT JOIN restriction_document AS rd ON rd.subpoena_id = s.id
LEFT JOIN restriction_document_item AS rdi ON rdi.restriction_document_create_id = rd.id
LEFT JOIN subpoena_send_info AS ssi ON ssi.subpoena_id = s.id
WHERE sr.type = '3'
AND ssh.code NOT IN ('3.14','3.7','3.72', '3.71')
AND (
COALESCE('${VK_ARRAY}', '') = ''
OR s.department_id = ANY (
string_to_array(
trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')),
','
)::uuid[]
)
)
),
last_status AS (
SELECT *
FROM subpoena_data
WHERE rn = 1
),
t1 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_subpoena
FROM last_status
WHERE sub_stat_hist IS NOT NULL
),
t2 AS (
SELECT ROUND(AVG(EXTRACT(DAY FROM (history_date::timestamp - send_date::timestamp))), 1) AS average_appeared
FROM last_status
WHERE sub_stat_hist IN ('4.1', '4.2', '4')
),
t3 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_appeared
FROM last_status
WHERE sub_stat_hist IN ('4.1', '4.2', '4')
),
t4 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_not_appeared
FROM last_status
WHERE sub_stat_hist = '5'
),
t5 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_not_ap_good_reason
FROM last_status
WHERE sub_stat_hist = '5.1'
),
t6 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_ap_not_required
FROM last_status
WHERE sub_stat_hist IN ('3.8', '5.2')
),
t7 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_restrictions_applied
FROM last_status
WHERE restr_dc IS NULL
),
t8 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_introduced_measures
FROM last_status
WHERE restr_dc IS NULL AND ap_date IS NOT NULL
),
t9 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_paper
FROM last_status
WHERE d_code != '7'
),
t10 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_electron
FROM last_status
WHERE d_code = '7'
),
t11 AS (
SELECT COUNT (DISTINCT rdi_id) AS count_restrictions
FROM last_status
),
t12 AS (
SELECT COUNT(DISTINCT subpoena_id) AS count_not_delivery
FROM last_status
WHERE d_code IS NULL
),
t13 AS (
SELECT COUNT(DISTINCT subpoena_id) AS appear_date_is_good
FROM last_status
WHERE sub_stat_hist IN ('3','3.12', '3.13', '3.15', '3.1')
)
SELECT
COALESCE(t1.count_subpoena, 0) AS count_subpoena,
COALESCE(t2.average_appeared, 0) AS average_appeared,
COALESCE(t3.count_appeared, 0) AS count_appeared,
COALESCE(t4.count_not_appeared, 0) AS count_not_appeared,
COALESCE(t5.count_not_ap_good_reason, 0) AS count_not_ap_good_reason,
COALESCE(t6.count_ap_not_required, 0) AS count_ap_not_required,
COALESCE(t7.count_restrictions_applied, 0) AS count_restrictions_applied,
COALESCE(t8.count_introduced_measures, 0) AS count_introduced_measures,
COALESCE(t9.count_paper, 0) AS count_paper,
COALESCE(t10.count_electron, 0) AS count_electron,
COALESCE(t11.count_restrictions, 0) AS count_restrictions,
COALESCE(t12.count_not_delivery, 0) AS count_not_delivery,
COALESCE(t13.appear_date_is_good, 0) AS appear_date_is_good,
ROUND(COALESCE(t3.count_appeared, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS appeared_percent,
ROUND(COALESCE(t4.count_not_appeared, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS not_appeared_percent,
ROUND(COALESCE(t5.count_not_ap_good_reason, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS not_ap_good_reason_percent,
ROUND(COALESCE(t6.count_ap_not_required, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS ap_not_required_percent,
ROUND(COALESCE(t10.count_electron, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS electron_percent,
ROUND(COALESCE(t9.count_paper, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS paper_percent,
ROUND(COALESCE(t7.count_restrictions_applied, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS restrictions_applied_percent,
ROUND(COALESCE(t8.count_introduced_measures, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS introduced_measures_percent,
ROUND(COALESCE(t12.count_not_delivery, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS not_delivery_percent,
ROUND(COALESCE(t13.appear_date_is_good, 0) * 100.0 / NULLIF(t1.count_subpoena, 0), 2) AS appear_date_is_good_percent,
'${REG_ID}' AS recruitment_id,
1 AS org,
0 AS rest,
'Осень' AS spring_autumn
FROM t1
FULL OUTER JOIN t2 ON true
FULL OUTER JOIN t3 ON true
FULL OUTER JOIN t4 ON true
FULL OUTER JOIN t5 ON true
FULL OUTER JOIN t6 ON true
FULL OUTER JOIN t7 ON true
FULL OUTER JOIN t8 ON true
FULL OUTER JOIN t9 ON true
FULL OUTER JOIN t10 ON true
FULL OUTER JOIN t11 ON true
FULL OUTER JOIN t12 ON true
FULL OUTER JOIN t13 ON true
WHERE NOT (
COALESCE('${VK_ARRAY}', '') = ''
AND (
COALESCE(t1.count_subpoena, 0) > 0
OR COALESCE(t2.average_appeared, 0) > 0
OR COALESCE(t3.count_appeared, 0) > 0
OR COALESCE(t4.count_not_appeared, 0) > 0
OR COALESCE(t5.count_not_ap_good_reason, 0) > 0
OR COALESCE(t6.count_ap_not_required, 0) > 0
OR COALESCE(t7.count_restrictions_applied, 0) > 0
OR COALESCE(t8.count_introduced_measures, 0) > 0
OR COALESCE(t9.count_paper, 0) > 0
OR COALESCE(t10.count_electron, 0) > 0
OR COALESCE(t11.count_restrictions, 0) > 0
OR COALESCE(t12.count_not_delivery, 0) > 0
OR COALESCE(t13.appear_date_is_good, 0) > 0
)
);</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>160</xloc>
<yloc>400</yloc>
<draw>Y</draw>
</GUI>
</transform>
<transform_error_handling>
</transform_error_handling>
<attributes/>
</pipeline>