SELECT
<output name="year" replace="(YEAR(t.time))" />AS year,
<output name="month" replace="(MONTHNAME(t.time))" chart="k" />AS month,
<output name="invoice" replace="(SUM(t.invoice))" chart="l" data="float" />AS invoice,
<output name="payments" replace="(SUM(t.payment))" chart="l" data="float" />AS payments,
<output name="lights" replace="CAST((SUM(service)) AS Decimal(8,2))" chart="d" data="float" />AS lights,
<output name="lights2" replace="CAST((SUM(service2)) AS Decimal(8,2))" chart="d" data="float" />AS lights2,
<output name="hose" replace="CAST((SUM(hose)) AS Decimal(8,2))" chart="d" data="float" />AS hose
FROM transac t
LEFT JOIN (SELECT v.datetime AS datetime, (v.quantity * s.charges) AS service FROM invitem v LEFT JOIN service s ON s.idservice = v.idservice WHERE s.idservice = 'PARTS-LIGHTS-VBFG-2' GROUP BY v.datetime) z ON z.datetime = t.time
LEFT JOIN (SELECT v.datetime AS datetime, (v.quantity * s.charges) AS service2 FROM invitem v LEFT JOIN service s ON s.idservice = v.idservice WHERE s.idservice = 'PARTS-LIGHT-FGRT-1' GROUP BY v.datetime) y ON y.datetime = t.time
LEFT JOIN (SELECT v.datetime AS datetime, (v.quantity * s.charges) AS hose FROM invitem v LEFT JOIN service s ON s.idservice = v.idservice WHERE s.idservice = 'UTILSRUBBERHOSE657' GROUP BY v.datetime) w ON w.datetime = t.time
WHERE DATE(time) between 'a year ago' AND DATE(NOW())
GROUP BY MONTHNAME(t.time)