-
-
Save parzibyte/bcfaaa9e08f9294ae1cbd49d57a46e6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getEmployeesWithAttendanceCount($start, $end) | |
{ | |
$query = "select employees.name, | |
sum(case when status = 'presence' then 1 else 0 end) as presence_count, | |
sum(case when status = 'absence' then 1 else 0 end) as absence_count | |
from employee_attendance | |
inner join employees on employees.id = employee_attendance.employee_id | |
where date >= ? and date <= ? | |
group by employee_id;"; | |
$db = getDatabase(); | |
$statement = $db->prepare($query); | |
$statement->execute([$start, $end]); | |
return $statement->fetchAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment