select task.regist_no as '报案号',task.license_no as '车牌号',task.vehicle_brand as '车辆品牌',
case task.task_type when '1' then '标的' when '2' then '三者' end as '送修类型',task.task_id as '任务ID',
garage.garage_name as '送修修理厂名称',garage.garage_code as '修理厂代码',
case garage.cooperate_type when '01' then '理赔合作' when '02' then '业务合作'
when '03' then '业务合作（VIP）' when '99' then '其他合作' end as '修理厂合作类型',
ty.type_name as '修理厂品牌', case  when garage.repair_tel is null then '否' else '是' end as '是否视频修理厂',
garage.org_id as '修理厂归属分公司机构',dispatch.task_source as '送修任务来源',case dispatch.status when '2' then '放弃' 
when '3' then '未抵厂' when '1' then '确认留修' when '0' then '未操作' else '其他' end as '修理厂操作',
dispatch.task_change_time as '任务流入时间',dispatch.out_time as '任务留出时间'
from ( select * from(
 select * from et_repair_task_dispatch  
 where create_time between '2018-01-01' and '2018-02-01' order by create_time desc
) dispatch
group by dispatch.garage_code,dispatch.task_id ) dispatch
left join et_repair_task task on task.task_id=dispatch.task_id
left join et_garage garage on dispatch.garage_code=garage.garage_code
left join et_type ty on ty.type_code=garage.category_code