Untitled

mail@pastecode.io avatar
unknown
pgsql
10 months ago
3.2 kB
3
Indexable
Never
WITH widget_data AS (select t17.phase_site_name  phase_site,t18.type_site_name  type_site,t16.candidate_name  active_by_agreement, t16.candidate_id  link_for_active_by_agreement,t1.clone_of_the_candidate_for_bc,t15.fio  responsible_search_engineer,t7.fio  responsible_rp,t3.site_number_region  is_optional, t3.site_id  link_for_is_optional,t2.operating_company_name  operating_company,t6.site_number_region  is_an_alternative, t6.site_id  link_for_is_an_alternative,t5.candidate_name  active_candidate, t5.candidate_id  link_for_active_candidate,t4.type_plan_name  type_plan,t1.site_id,t1.site_number,t1.site_number_thirdparty_operator,t20.candidate_name  active_in_operation, t20.candidate_id  link_for_active_in_operation,t1.is_approved_in_the_budget,t11.fio  responsible_cm,t10.operating_company_name  operating_company_owner,t1.date_rbi_reconciliation,t21.fio  responsible_engineer_pir_smr,t1.is_enabled_clone_synch,t19.macroregion_name  macroregion,t9.budget_name  available_in_the_budget,t8.region_name  region,t1.sub_region,t12.fio  responsible_for_transmission,t22.fio  resp_operation_engineer,t23.type_site_constructive_name2  type_site_constructive,t13.status_site_name  status_site,t24.capacity_plan_name  avail_in_terms_of_capacity,t14.status_site_ep_name  status_site_ep,t1.available_in_terms_of_coverage
from public.site t1 left join public.operating_company t2 on  t2.operating_company_id = t1.operating_company_id left join public.site t3 on  t3.site_id = t1.is_optional_id left join public.type_plan t4 on  t4.type_plan_id = t1.type_plan_id left join public.candidate t5 on  t5.candidate_id = t1.active_candidate_id left join public.site t6 on  t6.site_id = t1.is_an_alternative_id left join public.users t7 on  t7.user_id = t1.responsible_rp_id left join public.region t8 on  t8.region_id = t1.region_id left join public.budget t9 on  t9.budget_id = t1.available_in_the_budget_id left join public.operating_company t10 on  t10.operating_company_id = t1.operating_company_owner_id left join public.users t11 on  t11.user_id = t1.responsible_cm_id left join public.users t12 on  t12.user_id = t1.responsible_for_transmission_id left join public.status_site t13 on  t13.status_site_id = t1.status_site_id left join public.status_site_ep t14 on  t14.status_site_ep_id = t1.status_site_ep_id left join public.users t15 on  t15.user_id = t1.responsible_search_engineer_id left join public.candidate t16 on  t16.candidate_id = t1.active_by_agreement_id left join public.phase_site t17 on  t17.phase_site_id = t1.phase_site_id left join public.type_site t18 on  t18.type_site_id = t1.type_id left join public.macroregion t19 on  t19.macroregion_id = t1.macroregion_id left join public.candidate t20 on  t20.candidate_id = t1.active_in_operation_id left join public.users t21 on  t21.user_id = t1.responsible_engineer_pir_smr_id left join public.users t22 on  t22.user_id = t1.resp_operation_engineer_id left join public.type_site_constructive t23 on  t23.type_site_constructive_id = t1.type_site_constructive_id left join public.capacity_plan t24 on  t24.capacity_plan_id = t1.avail_in_terms_of_capacity_id)
select *, count(*) OVER() AS full_count
from widget_data
fetch next 1 rows only