SELECT type_id,max(type_name) as type_name,org_id_int as org_id,max(org_name) as org_name,
<iftest="sizeId !=null and sizeId != ''">
size_id,max(size_name) as size_name,
</if>
(sum((case when (`its`.`location_type` = 0) then `its`.`stock_number` else 0 end))+sum((case when (`its`.`location_type` = 0) then `its`.`outbound_number` else 0 end))+sum((case when (`its`.`location_type` = 0) then `its`.`destruction_number` else 0 end))) as number,
sum((case when (`its`.`location_type` = 0) then `its`.`stock_number` else 0 end)) AS `ck_stock_number`,
sum((case when (`its`.`location_type` = 0) then `its`.`outbound_number` else 0 end)) AS `ck_outbound_number`,
sum((case when (`its`.`location_type` = 0) then `its`.`destruction_number` else 0 end)) AS `destruction_number`,
sum((case when (`its`.`location_type` = 1) then `its`.`stock_number` else 0 end)) AS `djg_stock_number`,
sum((case when (`its`.`location_type` = 1) then `its`.`outbound_number` else 0 end)) AS `djg_outbound_number`