SELECT
cdrug.drugtype,
cdrug.drugcode,
cdrug.drugname,
SUM(visitdrug.unit) AS total,
SUM(CASE WHEN LEFT(visit.visitdate,4) + 543 = 2555 THEN visitdrug.unit ELSE '' END) AS '2555',
SUM(CASE WHEN LEFT(visit.visitdate,4) + 543 = 2556 THEN visitdrug.unit ELSE '' END) AS '2556',
SUM(CASE WHEN LEFT(visit.visitdate,4) + 543 = 2557 THEN visitdrug.unit ELSE '' END) AS '2557',
SUM(CASE WHEN LEFT(visit.visitdate,4) + 543 = 2558 THEN visitdrug.unit ELSE '' END) AS '2558'
FROM visitdrug
INNER JOIN cdrug ON visitdrug.drugcode = cdrug.drugcode
INNER JOIN visit ON visitdrug.visitno = visit.visitno and visitdrug.pcucode = visit.pcucode
WHERE LEFT(visit.visitdate,4) + 543 BETWEEN 2555 AND 2558
AND cdrug.drugtype IN ('01','10')
GROUP BY cdrug.drugname;