Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select gt_sf.name,
- gt_mo.name,
- ---форма ОВ-02
- CASE WHEN sewerage_wastewater_discharge_count < central_sewerage_systems_count THEN sewerage_wastewater_discharge_count||' < '||central_sewerage_systems_count
- ELSE '' END as "П1_V2_5<4",
- CASE WHEN treatment_facilities_total < treatment_facilities_first_cathegory+treatment_facilities_second_cathegory THEN treatment_facilities_total||' < '||treatment_facilities_first_cathegory+treatment_facilities_second_cathegory
- ELSE '' END as "П2_V2_8<6&7",
- CASE WHEN treatment_facilities_total != treatment_facilities_superlarge+treatment_facilities_largest+treatment_facilities_large+treatment_facilities_big+treatment_facilities_medium+treatment_facilities_small+treatment_facilities_little+treatment_facilities_ultra_small
- THEN treatment_facilities_total||' <> '||treatment_facilities_superlarge+treatment_facilities_largest+treatment_facilities_large+treatment_facilities_big+treatment_facilities_medium+treatment_facilities_small+treatment_facilities_little+treatment_facilities_ultra_small
- ELSE '' END as "П3_V2_8<>9&10&11&12&13&14&16",
- CASE WHEN treatment_facilities_total < project_indicators_complying_count+project_indicators_not_complying_count THEN treatment_facilities_total||' < '||project_indicators_complying_count+project_indicators_not_complying_count
- ELSE '' END as "П4_V2_8<V6_10&V6_13",
- CASE WHEN treatment_facilities_total < tech_indicators_complying_count+tech_indicators_not_complying_count THEN treatment_facilities_total||' < '||tech_indicators_complying_count+tech_indicators_not_complying_count
- ELSE '' END as "П5_V2_8<V6_11&V6_14",
- CASE WHEN treatment_facilities_total < indicators_complying_count+indicators_not_complying_count THEN treatment_facilities_total||' < '||indicators_complying_count+indicators_not_complying_count
- ELSE '' END as "П6_V2_8<V6_12&V6_15",
- CASE WHEN (pumping_station_total > 0 and networks_length_pressure_total = 0) or (pumping_station_total = 0 and networks_length_pressure_total > 0) THEN pumping_station_total||'/'||round(networks_length_pressure_total,1)
- ELSE '' END as "П7_V2_18/20",
- CASE WHEN networks_length_gravity_total = 0 THEN round(networks_length_gravity_total)||''
- ELSE '' END as "П8_V2_19=0",
- CASE WHEN (networks_length_pressure_total > 0 and pumping_station_total = 0) THEN round(networks_length_pressure_total,1)||'/'||round(pumping_station_total)
- ELSE '' END as "П9_V2_20/18",
- CASE WHEN sewerage_volume_in != clean_sewage_wastewater_volume
- THEN round(sewerage_volume_in,1)||' <> '||round(clean_sewage_wastewater_volume,1)
- ELSE '' END as "П10_V2_22<>V6_6",
- CASE WHEN sewerage_volume_out != vrr_cs.water_pollution
- THEN round(sewerage_volume_out,1)||' <> '||round(vrr_cs.water_pollution,1)
- ELSE '' END as "П11_V2_23<>V6_7",
- CASE WHEN (discharged_surface_wastewater > 0 and networks_length_total = 0) THEN round(networks_length_total,1)||'/'||round(discharged_surface_wastewater,1)
- ELSE '' END as "П12_V2_21/24",
- CASE WHEN discharged_surface_wastewater < surface_wastewater_flowing_rain_sewer THEN round(discharged_surface_wastewater,1)||' < '||round(surface_wastewater_flowing_rain_sewer,1)
- ELSE '' END as "П13_V2_25>24",
- CASE WHEN (pumping_station_total > 0 and design_parameters = 0) or (pumping_station_total = 0 and design_parameters > 0) THEN pumping_station_total||'/'||round(design_parameters,1)
- ELSE '' END as "П14_V2_18/27",
- CASE WHEN design_parameters < actual_parameters THEN round(design_parameters,1)||' < '||round(actual_parameters,1)
- ELSE '' END as "П15_V2_28>27",
- ---форма ОВ-03
- CASE WHEN power_consumption_cleaning_parameters > 10000 or power_consumption_cleaning_parameters < 100 THEN round(power_consumption_cleaning_parameters,1) ||' должно быть в диапазоне 100 до 10000 '
- ELSE '' END as "П16_V3_9in[100..10000]",
- CASE WHEN (networks_length_pressure_total > 0 and power_consumption_sewerage_objects = 0) or (networks_length_pressure_total = 0 and power_consumption_sewerage_objects > 0) THEN round(networks_length_pressure_total,1)||'/'||round(power_consumption_sewerage_objects,1)
- ELSE '' END as "П17_V2_20/V3_10",
- CASE WHEN power_consumption_sewerage_objects < 0 or power_consumption_sewerage_objects > 10000 THEN round(power_consumption_sewerage_objects,1) ||' должно быть в диапазоне 0 до 10000 '
- ELSE '' END as "П17-1_V3_10in[0..10000]",
- CASE WHEN accidents_count > 2 THEN round(accidents_count) ||' > 2'
- ELSE '' END as "П18_V3_11>2",
- CASE WHEN count_queues_total != count_queues_1960+count_queues_1970+count_queues_1980+count_queues_1991+count_queues_2000+count_queues_2010+count_queues_2018
- THEN treatment_facilities_total||' <> '||count_queues_1960+count_queues_1970+count_queues_1980+count_queues_1991+count_queues_2000+count_queues_2010+count_queues_2018
- ELSE '' END as "П19_V3_12<>13&14&15&16&17&18&19",
- CASE
- WHEN treatment_facilities_total =0 or treatment_facilities_total is NULL THEN ''
- WHEN treatment_facilities_total =0 and count_queues_total>0 THEN treatment_facilities_total || ' Укажите количество ОСК'
- WHEN (count_queues_total/treatment_facilities_total<1) or (count_queues_total/treatment_facilities_total>10) THEN round(count_queues_total) ||' / '|| round(treatment_facilities_total)
- ELSE '' END as "П20_V3_12/V2_8",
- ---форма ОВ-03
- CASE WHEN treatment_facilities_ownerless_count+treatment_facilities_gup_exploit_count+treatment_facilities_mo_exploit_count > treatment_facilities_total THEN round(treatment_facilities_ownerless_count+treatment_facilities_gup_exploit_count+treatment_facilities_mo_exploit_count) ||' > '|| round(treatment_facilities_total)
- ELSE '' END as "П21_V4_3+4+5>V2_8",
- CASE WHEN treatment_facilities_ownerless_count+treatment_facilities_rent_exploit_count+treatment_facilities_conv_exploit_count > treatment_facilities_total THEN round(treatment_facilities_ownerless_count+treatment_facilities_rent_exploit_count+treatment_facilities_conv_exploit_count) ||' > '|| round(treatment_facilities_total)
- ELSE '' END as "П22_V4_3+6+7>V2_8",
- CASE WHEN pumping_station_count+pumping_station_gup_exploit_count+pumping_station_mo_exploit_count > pumping_station_total THEN round(pumping_station_count+pumping_station_gup_exploit_count+pumping_station_mo_exploit_count) ||' > '|| round(pumping_station_total)
- ELSE '' END as "П23_V4_8+9+10>V2_18",
- CASE WHEN pumping_station_count+pumping_station_rent_exploit_count+pumping_station_conv_exploit_count > pumping_station_total THEN round(pumping_station_count+pumping_station_rent_exploit_count+pumping_station_conv_exploit_count) ||' > '|| round(pumping_station_total)
- ELSE '' END as "П24_V4_8+11+12>V2_18",
- CASE WHEN networks_ownerless_length+networks_ownerless_gup_exploiting_length+networks_ownerless_mo_exploiting_length > networks_length_gravity_total+networks_length_pressure_total THEN round(networks_ownerless_length+networks_ownerless_gup_exploiting_length+networks_ownerless_mo_exploiting_length,1) ||' > '|| round(networks_length_gravity_total+networks_length_pressure_total,1)
- ELSE '' END as "П25_V4_13+14+15>V2_19+20",
- CASE WHEN networks_ownerless_length+networks_ownerless_rent_exploiting_length+networks_ownerless_conv_exploiting_length > networks_length_gravity_total+networks_length_pressure_total THEN round(networks_ownerless_length+networks_ownerless_rent_exploiting_length+networks_ownerless_conv_exploiting_length, 1) ||' > '|| round(networks_length_gravity_total+networks_length_pressure_total,1)
- ELSE '' END as "П26_V4_13+16+17>V2_19+20",
- ---форма ОВ-05_1
- CASE WHEN population != central_sewerage_systems_provided+without_sewerage_population_total THEN round(population) ||' <> '|| round(central_sewerage_systems_provided+without_sewerage_population_total)
- ELSE '' END as "П27_V51_3<>4+9",
- CASE WHEN (sewerage_volume_wastes_from_citizens > 0 and sewerage_volume_wastes = 0) THEN round(sewerage_volume_wastes_from_citizens,1)||'/'||round(sewerage_volume_wastes,1)
- ELSE '' END as "П28_V51_6/7",
- CASE WHEN (sewerage_volume_wastes > 0 and without_sewerage_population_wastes_export = 0) THEN round(sewerage_volume_wastes,1)||'/'||round(without_sewerage_population_wastes_export,1)
- ELSE '' END as "П29_V51_7/10",
- '' as "П30",
- CASE WHEN without_sewerage_population_total != population-central_sewerage_systems_provided THEN round(without_sewerage_population_total) ||' <> '|| round(population-central_sewerage_systems_provided)
- ELSE '' END as "П31_V51_9<>3-4",
- CASE WHEN without_sewerage_population_wastes_export > without_sewerage_population_total THEN round(without_sewerage_population_wastes_export) ||' > '|| round(without_sewerage_population_total)
- ELSE '' END as "П32_V51_10>9",
- CASE WHEN without_sewerage_population_wastes_export != decentralized_sewerage_systems_provided THEN round(without_sewerage_population_wastes_export) ||' <> '|| round(decentralized_sewerage_systems_provided)
- ELSE '' END as "П33_V51_10<>5",
- CASE WHEN implemented_total != implemented_first_half+implemented_second_half+implemented_other_consumers THEN round(implemented_total,1) ||' <> '|| round(implemented_first_half+implemented_second_half+implemented_other_consumers,1)
- ELSE '' END as "П34_V51_11<>12+13+14",
- CASE
- WHEN (central_sewerage_systems_provided=0) OR (central_sewerage_systems_provided is NULL) THEN central_sewerage_systems_provided || ' заполните графу 4'
- WHEN (decentralized_sewerage_systems_provided=0) OR (decentralized_sewerage_systems_provided is NULL) THEN decentralized_sewerage_systems_provided || ' заполните графу 5'
- WHEN ((implemented_first_half+implemented_second_half)*1000/(central_sewerage_systems_provided+decentralized_sewerage_systems_provided)::numeric/12<1) or ((implemented_first_half+implemented_second_half)*1000/(central_sewerage_systems_provided+decentralized_sewerage_systems_provided)::numeric/12>15) THEN round((implemented_first_half+implemented_second_half)*1000/(central_sewerage_systems_provided+decentralized_sewerage_systems_provided)::numeric/12,2) || ' должно быть в диапазоне от 1 до 15 '
- ELSE '' END as "П35_V51_12+13in[1..15]",
- CASE
- WHEN implemented_second_half < implemented_first_half*0.5 or (implemented_second_half > implemented_first_half*2) THEN round(implemented_second_half,1) ||' должно быть в диапазоне '||'['||round(implemented_first_half*0.5,1)||'..'||round(implemented_first_half*2,1)||']'
- ELSE '' END as "П36_V51_13in12*[0.5..2]",
- CASE
- WHEN other_customers_tariff=0 and implemented_other_consumers <>0 THEN round(implemented_other_consumers,1) ||'/ '|| round(other_customers_tariff,1)
- ELSE '' END as "П37_V51_14/17",
- CASE WHEN (implemented_other_consumers > 0 and other_customers_tariff = 0) THEN round(implemented_other_consumers,1)||'/'||round(other_customers_tariff,1)
- ELSE '' END as "П38_V51_14/17",
- CASE
- WHEN (first_half_tariff<4) or (first_half_tariff>250) THEN round(first_half_tariff,1) || ' должно быть в диапазоне от 4 до 250 '
- ELSE '' END as "П39_V51_15in[4..250]",
- CASE
- WHEN (second_half_tariff<first_half_tariff*0.5) or (second_half_tariff>first_half_tariff*1.5) THEN round(second_half_tariff,1) || ' должно быть в диапазоне '||'['||round(first_half_tariff*0.5,1)||'..'||round(first_half_tariff*1.5,1)||']'
- ELSE '' END as "П40_V51_16in15*[0.5..1.5]",
- CASE
- WHEN (second_half_tariff<4) or (second_half_tariff>250) THEN round(second_half_tariff,1) || ' должно быть в диапазоне от 4 до 250 '
- ELSE '' END as "П41_V51_16in[4..250]",
- CASE
- WHEN other_customers_tariff>second_half_tariff*5 THEN round(other_customers_tariff,1) || ' > '||round(second_half_tariff*5,1)
- ELSE '' END as "П42_V51_17>16*5" ,
- CASE
- WHEN first_half_tariff>second_half_tariff and first_half_tariff>other_customers_tariff and amount_of_receivables > first_half_tariff*implemented_total*3 THEN round(amount_of_receivables,1) || ' > '||round(first_half_tariff*implemented_total*3,1)
- WHEN second_half_tariff>first_half_tariff and second_half_tariff>other_customers_tariff and amount_of_receivables > second_half_tariff*implemented_total*3 THEN round(amount_of_receivables,1) || ' > '||round(second_half_tariff*implemented_total*3,1)
- WHEN other_customers_tariff>second_half_tariff and other_customers_tariff> first_half_tariff and amount_of_receivables > other_customers_tariff*implemented_total*3 THEN round(amount_of_receivables,1) || ' > '||round(other_customers_tariff*implemented_total*3,1)
- ELSE '' END as "П43_V51_18>max(15,16,17)&11*3",
- CASE
- WHEN first_half_tariff<second_half_tariff and first_half_tariff<other_customers_tariff and amount_of_receivables < first_half_tariff*implemented_total/12 THEN round(amount_of_receivables,1) || ' < '||round(first_half_tariff*implemented_total/12,1)
- WHEN second_half_tariff<first_half_tariff and second_half_tariff<other_customers_tariff and amount_of_receivables < second_half_tariff*implemented_total/12 THEN round(amount_of_receivables,1) || ' < '||round(second_half_tariff*implemented_total/12,1)
- WHEN other_customers_tariff<second_half_tariff and other_customers_tariff< first_half_tariff and amount_of_receivables < other_customers_tariff*implemented_total/12 THEN round(amount_of_receivables,1) || ' < '||round(other_customers_tariff*implemented_total/12,1)
- ELSE '' END as "П44_V51_18<min(15,16,17)&11/12",
- ---форма ОВ-05_2
- CASE
- WHEN amount_payable < power_consumption_cleaning_parameters*implemented_total/1000/12*1.5 THEN round(amount_payable,1) || ' < '||round(power_consumption_cleaning_parameters*implemented_total/1000/12*1.5,3)
- ELSE '' END as "П45_V52_18-1",
- CASE
- WHEN first_half_tariff>second_half_tariff and first_half_tariff>other_customers_tariff and amount_payable >= power_consumption_cleaning_parameters*implemented_total*first_half_tariff/1000*10 THEN round(amount_payable,1) || ' > '||round(power_consumption_cleaning_parameters*implemented_total*first_half_tariff/1000*10,1)
- WHEN second_half_tariff>first_half_tariff and second_half_tariff>other_customers_tariff and amount_payable >= power_consumption_cleaning_parameters*implemented_total*second_half_tariff/1000*10 THEN round(amount_payable,1) || ' > '||round(power_consumption_cleaning_parameters*implemented_total*second_half_tariff/1000*10,1)
- WHEN other_customers_tariff>second_half_tariff and other_customers_tariff> first_half_tariff and amount_payable >= power_consumption_cleaning_parameters*implemented_total*other_customers_tariff/1000*10 THEN round(amount_payable,1) || ' > '||round(power_consumption_cleaning_parameters*implemented_total*other_customers_tariff/1000*10,1)
- ELSE '' END as "П46_V52_18-1",
- CASE
- WHEN investment_program_approval_count > financial_assets_profit_count+financial_assets_lesion_count THEN round(investment_program_approval_count) || ' > '||round(financial_assets_profit_count+financial_assets_lesion_count)
- ELSE '' END as "П47_V52_18-2>18-8&18-10",
- CASE WHEN (financial_assets_total > 0 and investment_program_approval_count = 0) THEN round(investment_program_approval_count)||'/'||round(financial_assets_total,1)
- ELSE '' END as "П48_V52_18-2/18-3",
- CASE
- WHEN financial_assets_total > financial_assets_depreciation_sum+financial_assets_capital_expenditure_sum+financial_assets_budget+financial_assets_other_sources_sum THEN round(financial_assets_total,1) || ' <> '||round(financial_assets_depreciation_sum+financial_assets_capital_expenditure_sum+financial_assets_budget+financial_assets_other_sources_sum,1)
- ELSE '' END as "П49_V52_18-3<>18-4&18-5&18-6&18-7",
- CASE WHEN (financial_assets_total = 0 and investment_program_approval_count > 0) THEN round(financial_assets_total,1)||'/'||round(investment_program_approval_count)
- ELSE '' END as "П50_V52_18-3/18-2",
- CASE WHEN (financial_assets_profit_count > 0 and financial_assets_profit < 0) THEN round(financial_assets_profit_count)||'/'||round(financial_assets_profit,1)
- ELSE '' END as "П51_V52_18-8/18-9" ,
- CASE WHEN ( financial_assets_profit >= 0 and financial_assets_profit_count < 0) THEN round(financial_assets_profit,1)||'/'||round(financial_assets_profit_count)
- ELSE '' END as "П52_V52_18-9/18-8",
- CASE WHEN ( financial_assets_lesion_count > 0 and financial_assets_lesion = 0) THEN round(financial_assets_lesion_count)||'/'||round(financial_assets_lesion,1)
- ELSE '' END as "П53_V52_18-10/18-11",
- CASE WHEN ( financial_assets_lesion > 0 and financial_assets_lesion_count = 0) THEN round(financial_assets_lesion,1)||'/'||round(financial_assets_lesion_count)
- ELSE '' END as "П54_V52_18-11/18-10",
- ---форма ОВ-05_2
- CASE WHEN wastewater_inflow*24/1000 < clean_sewage_actual_inflow*0.7 or wastewater_inflow*24/1000 > clean_sewage_actual_inflow*1.1 THEN round(wastewater_inflow*24/1000,1)|| ' должно быть в диапазоне '||'['||round(clean_sewage_actual_inflow*0.7,1)||'..'||round(clean_sewage_actual_inflow*1.1,1)||']'
- ELSE '' END as "П55_V6_3in5*[0.7..1.1]",
- CASE WHEN clean_sewage_performance < clean_sewage_actual_inflow*0.3 or clean_sewage_performance > clean_sewage_actual_inflow*10 THEN round(clean_sewage_performance,1)|| ' должно быть в диапазоне '||'['||round(clean_sewage_actual_inflow*0.3,1)||'..'||round(clean_sewage_actual_inflow*10,1)||']'
- ELSE '' END as "П56_V6_4in5*[0.3..10]",
- CASE WHEN clean_sewage_actual_inflow*365 < sewerage_volume_in*0.9 or clean_sewage_actual_inflow > sewerage_volume_in*1.1 THEN round(clean_sewage_actual_inflow*365,1)|| ' должно быть в диапазоне '||'['||round(sewerage_volume_in*0.9,1)||'..'||round(sewerage_volume_in*1.1,1)||']'
- ELSE '' END as "П57_V6_5inV2_22*[0.9..1.1]",
- CASE WHEN clean_sewage_wastewater_volume < (vrr_cs.water_pollution+water_pollution_excess+water_clear_standart)*0.9 or clean_sewage_wastewater_volume > vrr_cs.water_pollution+water_pollution_excess+water_clear_standart THEN round(clean_sewage_wastewater_volume,1)|| ' должно быть в диапазоне '||'['||round(vrr_cs.water_pollution+water_pollution_excess+water_clear_standart*0.9,1)||'..'||round(vrr_cs.water_pollution+water_pollution_excess+water_clear_standart,1)||']'
- ELSE '' END as "П58_V6_6in_7*8*9[0.9..1.1]",
- CASE WHEN vrr_cs.water_pollution != sewerage_volume_out THEN round(vrr_cs.water_pollution,1)|| ' <> '||round(vrr_cs.water_pollution,1)
- ELSE '' END as "П59_V6_7<>V2_23",
- CASE WHEN vrr_cs.water_pollution > sewerage_volume_in THEN round(vrr_cs.water_pollution,1)|| ' > '||round(sewerage_volume_in,1)
- ELSE '' END as "П59_1_V6_7>V2_22",
- CASE WHEN water_pollution_excess > clean_sewage_wastewater_volume THEN round(water_pollution_excess,1)|| ' > '||round(clean_sewage_wastewater_volume,1)
- ELSE '' END as "П60_V6_8>6",
- CASE WHEN water_clear_standart > clean_sewage_wastewater_volume THEN round(water_clear_standart,1)|| ' > '||round(clean_sewage_wastewater_volume,1)
- ELSE '' END as "П61_V6_9>6",
- CASE WHEN project_indicators_complying_count+project_indicators_not_complying_count > treatment_facilities_total THEN round(project_indicators_complying_count+project_indicators_not_complying_count)|| ' > '||round(treatment_facilities_total)
- ELSE '' END as "П62_V6_10&13>V2_8",
- CASE WHEN tech_indicators_complying_count+tech_indicators_not_complying_count > treatment_facilities_total THEN round(tech_indicators_complying_count+tech_indicators_not_complying_count)|| ' > '||round(treatment_facilities_total)
- ELSE '' END as "П63_V6_11&14>V2_8",
- CASE WHEN indicators_complying_count+indicators_not_complying_count > treatment_facilities_total THEN round(indicators_complying_count+indicators_not_complying_count)|| ' > '||round(treatment_facilities_total)
- ELSE '' END as "П64_V6_12&15>V2_8" ,
- CASE WHEN treatment_facilities_biofilter_count+treatment_facilities_remove_nitrogen_count+treatment_facilities_before_cleaning_count > treatment_facilities_total*3 THEN round(treatment_facilities_biofilter_count+treatment_facilities_remove_nitrogen_count+treatment_facilities_before_cleaning_count)|| ' > '||round(treatment_facilities_total*3)
- ELSE '' END as "П65_V6_16&17&18>V2_8"
- from volga_river_recovery.sewerages_reports vrr_sf
- join geo_tags gt_sf on gt_sf.id=vrr_sf.geo_tag_id
- join volga_river_recovery.sewerages_reports_mo vrr_mo on vrr_mo.sewerage_report_id=vrr_sf.id
- join geo_tags gt_mo on gt_mo.id=vrr_mo.geo_tag_id
- join volga_river_recovery.sewerages_reports_mo_clean_sewage vrr_cs on vrr_cs.municipal_area_id=vrr_mo.id
- join volga_river_recovery.sewerages_reports_mo_css vrr_css on vrr_css.municipal_area_id=vrr_mo.id
- join volga_river_recovery.sewerages_reports_mo_css_exploitation vrr_ce on vrr_ce.municipal_area_id=vrr_mo.id
- join volga_river_recovery.sewerages_reports_mo_css_state vrr_cst on vrr_cst.municipal_area_id=vrr_mo.id
- join volga_river_recovery.sewerages_reports_mo_service_implementation vrr_si on vrr_si.municipal_area_id=vrr_mo.id
- /*
- join volga_river_recovery.sewerages_reports_status_changes_rel vrr_report on vrr_report.sewerage_report_id=vrr_sf.id
- join public.status_changes on status_changes.id= vrr_report.status_change_id
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement