select o.org_desc as '分公司',task.regist_no as '报案号',task.task_id as '任务ID',task.license_no as '车牌号',
task.vehicle_brand as '车辆品牌',case when task.car_type='1' then '标的' when task.car_type='2' then '三者' end as '送修类型',
dispatch.task_source as '首次送修下发方',dispatch.distribute_account as '送修人员',dispatch.distribute_phone as '送修手机号',
dispatch.garage_name as '首次送修修理厂', case dispatch.cooperate_type when '01' then '理赔合作' when '02' then '业务合作'
when '03' then '业务合作（VIP）' when '99' then '其他合作' end as '首次送修修理厂合作类型',dispatch.create_time as '首次送修时间',
case dispatch.status when '2' then '放弃' when '3' then '未抵厂' when '1' then '确认留修' 
when '0' then '未操作' else '其他' end as '首次修理厂操作',task.update_by as '最终送修下方',task.user_account as '最终送修人员',
task.user_phone as '最终送修手机号',task.garage_name as '最终送修修理厂',case task.cooperate_type when '01' then '理赔合作' when '02' then '业务合作'
when '03' then '业务合作（VIP）' when '99' then '其他合作' end as '最终送修修理厂合作类型',task.update_time as '最终送修时间',
case task.status when '2' then '放弃' when '3' then '未抵厂' when '1' then '确认留修' 
when '0' then '未操作' else '其他' end as '最终修理厂操作',
case task.status when '0' then '送修发起' when '1' then '维修中' when '2' then '车辆抵场放弃' when '3' then '车辆未抵厂放弃'
when '4' then '用户取消放弃' when '5' then '车辆已修好' when '6' then '用户提车确认' 
when '7' then '用户评分完成' when '8' then '注销' when '10' then '查勘员终结' 
else '其他' end as '送修状态',task.confirm_time as '修理厂确认送修时间', task.finish_time as '修理厂完成时间',
task.ev_time as '客户评价时间'
from
(select task.*,garage.garage_name,garage.cooperate_type from et_repair_task_dispatch task 
 left join et_garage garage on garage.garage_code=task.garage_code
 where task.create_time>'2018-01-01' and task.create_time<'2018-02-01' group by task_id) dispatch
left join 
(select task.*,garage.garage_name,garage.cooperate_type from et_repair_task task 
 left join et_garage garage on garage.garage_code=task.garage_code
 where task.create_time>'2018-01-01' and task.create_time<'2018-02-01') task
on task.task_id=dispatch.task_id
left join et_org_info o on o.org_code=task.org_id