SELECT DISTINCT
CE.id,
SE.SubID,
C.region1_name AS Region,
C.sub_region1_name,
C.sub_region2_name,
C.sub_region4_name,
C.country_name,
SE.Work_Order_City,
SE.first_onsite_actual_start_time_date_ltz,
SE.work_order_state_or_province,
SE.Work_Order_Postal_Code,
CE.case_state AS State,
CV.primary_contact_full_addr,
CV.primary_contact_city,
CV.zip_code,
CE.rerepair_30,
CE.closed_date AS QYM,
SE.Delivery_Alternative,
CE.Business_Segment,
CE.CDAX_Business_Segment,
SE.Delay_Code,
CE.OTC,
SE.Repair_Class,
SE.Incident_type,
CE.Case_Type,
ZC.travel_zone,
SE.Reschedule_Reason,
C2.i04a_missed,
CE.I05a_Case,
CE.I05a_Missed,
CE.I06a_Case,
CE.I06a_Missed,
C2.i05d_case AS I05d_nonMC_case,
C2.I05d_MISSED AS I05d_nonMC_missed,
SE.HPCE,
SE.product_identifier,
PRODUCT.PRODUCT_NAME_NAME,
PRODUCT.PRODUCT_NUMBER_DESC,
C2.Product_Family,
C2.Product_Family_description,
CE.Serial_Number,
SE.Service_Category,
CE.Sla_Modifier_Repair_Time,
CE.Sla_Modifier_Response_Time,
CE.Service_Flag,
CV.case_title,
CE.Customer_Name,
PD.Part_Number,
PD.Part_Order_Detail_Description,
CA.Title_Name,
WO.MSDYN_Work_Order_Summary_Text,
CE.Opened_Date AS Case_Opened_Date,
CE.Opened_Date_LTZ AS Case_Opened_Date_LTZ,
CE.Closed_Date_LTZ AS Case_Closed_Date,
SE.Opened_Date_LTZ,
SE.rdt_ltz,
SE.First_Onsite_Actual_Start_Time_Date_LTZ AS Arrival_Time_Customer,
SE.Last_Fixed_On_Date_Date_LTZ AS End_Time_Customer,
SE.Closed_Date_LTZ,
SE.Last_Onsite_Actual_Start_Time_Date_LTZ,
SE.Due_Date_LTZ,
SE.Onsite_Fix_Time_LTZ,
SE.Onsite_Labor_Time,
SE.Last_Fixed_On_Date_Date_LTZ AS Onsite_Stop_Date,
SE.MPS_Flag,
SE.Status,
CE.Delivery_Motion,
CE.WO_Count,
CV.hpce_manager_name,
CE.sit_bd,
SE.reschedule_flag,
WO.Travel_Zone_Number,
WO.MSDYN_Instruction_Text,
WO.Tracking_number_name
FROM
innovation_services.lens-csdw_manage_case.fact_service_field_operations_header_denormalized_view AS CE
LEFT JOIN
innovation_services.lens-csdw_manage_case.fact_service_field_operations_item_denormalized_view AS SE ON SE.id = CE.id
LEFT JOIN
innovation_services.lens-csdw_manage_case.fact_service_field_operations_part_order_detail_denormalized_view AS PD ON SE.subid = PD.subid
LEFT JOIN
innovation_services.lens-csdw_manage_case.fact_service_field_operations_attributes_header_denormalized_view AS C2 ON C2.id = SE.id
LEFT JOIN
innovation_services.lens-csdw_common_dimension.dim_service_geography_hierarchy_view AS C ON CE.country_code = C.iso_country_code
LEFT JOIN
innovation_services.lens-csdw_common_dimension.dim_service_business_area_hierarchy_view AS D ON CE.hwpl = D.Product_Line_key
LEFT JOIN
innovation_services.lens-csdw_manage_case.dim_secured_ops_map_employee_field_partner_view AS maps ON SE.hpce_emp_number = maps.emp_num
LEFT JOIN
innovation_services.lens-csdw_manage_case.dim_secured_zipcode_customer_class_commercial_usnc_view AS ZC ON SE.zipcode_key = ZC.zipcode_key
LEFT JOIN
innovation_services.lens-csdw_common_dimension.dim_service_product_hierarchy_pmaster_view AS PRODUCT ON SE.product_identifier = PRODUCT.key
LEFT JOIN
innovation_services.lens-csdw_customer_service.fact_service_case_attribute_view AS CA ON SE.id = CA.Title_Name
LEFT JOIN
innovation_services.lens-csdw_manage_case.fact_secure_case_view AS CV ON SE.id = CV.id
LEFT JOIN
innovation_services.lens-csdw_customer_service.fact_service_work_order_view AS WO ON SE.subid = WO.MSDYN_Name
WHERE
CE.closed_date_ltz >= DATEADD(MONTH, -25, GETDATE()) AND CE.cdax_business_segment= "dMPS";