SELECT `a`.*, `b`.`code`, `b`.`name`, `d`.`name` as `departmentName`
FROM `hr__leave_allocation` `a`
JOIN `hr__leave_type` `b` ON `b`.`id` = `a`.`type_id`
JOIN `user__employment_detail` `c` ON `c`.`user_id` = `a`.`user_id`
JOIN `company__department` `d` ON `d`.`id` = `c`.`department_id`
WHERE `a`.`user_id` = '23'
AND `a`.`year` = '2019'
AND `a`.`is_delete` =0
ORDER BY `a`.`year` DESC, `a`.`type_id` ASC