SELECT a.*, b.name as companyName, c.year, c.month, c.totalHoursApplied, c.totalHoursApproved, c.otID, c.noofclaim, c.Pending as Pending, c.Rejected as Rejected, c.Approved as Approved, d.name
FROM `user__employment_detail` `a`
LEFT JOIN company__business_entity b ON b.id = a.business_entity_id
LEFT JOIN view_ot c ON a.user_id = c.peopleid
LEFT JOIN user d ON d.id = c.peopleid
WHERE `a`.`department_id` IS NULL
AND `c`.`month` = '6'
GROUP BY `b`.`id`, `c`.`peopleid`, `c`.`year`, `c`.`month`
ORDER BY 1, 2