select
case month(a.consignment_date) when ‘1‘ then sum(a.weight) else 0 end as 1月,
case month(a.consignment_date) when ‘2‘ then sum(a.weight) else 0 end as 2月,
case month(a.consignment_date) when ‘3‘ then sum(a.weight) else 0 end as 3月,
case month(a.consignment_date) when ‘4‘ then sum(a.weight) else 0 end as 4月,
case month(a.consignment_date) when ‘5‘ then sum(a.weight) else 0 end as 5月,
case month(a.consignment_date) when ‘6‘ then sum(a.weight) else 0 end as 6月,
case month(a.consignment_date) when ‘7‘ then sum(a.weight) else 0 end as 7月,
case month(a.consignment_date) when ‘8‘ then sum(a.weight) else 0 end as 8月,
case month(a.consignment_date) when ‘9‘ then sum(a.weight) else 0 end as 9月,
case month(a.consignment_date) when ‘10‘ then sum(a.weight) else 0 end as 10月,
case month(a.consignment_date) when ‘11‘ then sum(a.weight) else 0 end as 11月,
case month(a.consignment_date) when ‘12‘ then sum(a.weight) else 0 end as 12月,
a.department AS 部门,
b.dealings_abbreviation AS 供应商
from bm_shipment_quantity a left join bd_current_unit_alias b on a.supplier=b.id
where date_format(a.consignment_date, ‘%Y‘) IN (‘2019‘,‘2020‘,‘2021‘,‘2022‘,‘2023‘,‘2024‘,‘2025‘,‘2026‘,‘2027‘,‘2028‘)
GROUP BY a.consignment_date,a.weight