Please use field value as a column name then you can easily solved this.
Use below query:
SELECT leaves
.id, SUM( CASE WHEN (leaves
.type=”Annual”) THEN leaves
.noOfDays ELSE NULL END ) AS Annual, SUM( CASE WHEN (leaves
.type=”Casual”) THEN leaves
.noOfDays ELSE NULL END ) AS Casual, SUM( CASE WHEN (leaves
.type=”Medical”
) THEN leaves
.noOfDays ELSE NULL END ) AS Medical, SUM( CASE WHEN (leaves
.type=”Other” ) THEN leaves
.noOfDays ELSE NULL END ) AS Other,
leaves
.emp_id, employee.employeeCode, employee.employeeName, employee.designation, department.name
AS department, employee.email, employee.annualLeave, employee.casualLeave, employee.medicalLeave, employee.carryForward, YEAR( dateFrom ) AS YEAR, DATE_FORMAT( dateFrom, ‘%b’ ) AS
MONTH , SUM( leaves
.noOfDays ) AS totalNoLeaves
FROM employee
INNER JOIN department ON ( employee.deptt_id = department.id )
LEFT JOIN leaves
ON ( employee.id = leaves
.emp_id )
WHERE employee.id = ‘1’
GROUP BY DATE_FORMAT(leaves
.dateFrom, ‘%b’)
ORDER BY employee.id ASC
solved show leave record in each month