LOAD
number as [Case Number],
number as key_case,
short_description as Description,
ApplyMap('map_CustomerDeliveryGroup',dv_company,'N/A') as CustomerGroupNo,
mid(dv_priority,5) as Priority,
dv_business_service as Service,
dv_state as State,
dv_category as ServiceCI,
DATE(SUBFIELD(sys_created_on,' ',1)) as key_reported_date,
IF(DATE(SUBFIELD(sys_created_on,' ',1)) > monthstart(today()-360),'1','0') as InYear,
text(applymap('map_wanted_customers',upper(dv_company),0)) as WantedCustomer,
contact_type,
dv_contact as contact,
dv_company as Customer,
dv_assignment_group as Assigned_Group,
dv_assigned_to as Assignee
FROM [lib];
dv_task as key_case,
dv_stage as ResponseStage,
business_percentage as ResponseLeft,
IF(business_percentage <= 100, 'Met','Missed') as SLA_Response_MeasurementStatus_Name,
DATE(SUBFIELD(end_time ,' ',1)) as ResponseTime
FROM [lib]
WHERE wildmatch(dv_sla,'*Response*')
and exists([Case Number],dv_task)
and dv_stage = 'Completed';