$sql = "SELECT
equipment_code,
BINARY SUM((case DATE_FORMAT(date,'%m') when '01' time time else NULL end)) AS month_01,
BINARY SUM((case DATE_FORMAT(date,'%m') when '02' then time else NULL end)) AS month_02,
BINARY SUM((case DATE_FORMAT(date,'%m') when '03' then time else NULL end)) AS month_03,
BINARY SUM((case DATE_FORMAT(date,'%m') when '04' then time else NULL end)) AS month_04,
BINARY SUM((case DATE_FORMAT(date,'%m') when '05' then time else NULL end)) AS month_05,
BINARY SUM((case DATE_FORMAT(date,'%m') when '06' then time else NULL end)) AS month_06,
BINARY SUM((case DATE_FORMAT(date,'%m') when '07' then time else NULL end)) AS month_07,
BINARY SUM((case DATE_FORMAT(date,'%m') when '08' then time else NULL end)) AS month_08,
BINARY SUM((case DATE_FORMAT(date,'%m') when '09' then time else NULL end)) AS month_09,
BINARY SUM((case DATE_FORMAT(date,'%m') when '10' then time else NULL end)) AS month_10,
BINARY SUM((case DATE_FORMAT(date,'%m') when '11' then time else NULL end)) AS month_11,
BINARY SUM((case DATE_FORMAT(date,'%m') when '12' then time else NULL end)) AS month_12
FROM time_machine GROUP BY equipment_code";