Hi,
I'm storing student's attendance. It stores the in the present column true or false along with the day column.
I'm fetching the attendance of the current month. I want to show countof total present students and total absent students each day.
So far I managed to get the absent students but how can I get present student at the same time ?
Here is my query to get absent students count for each day of the selected month.
Table structure
id
student_id -> Student's ID which student was present or absent
day -> Attendance day
present -> false == absent, true == present
$ViewAttendance = DB::table("students_attendances")->whereRaw('extract(month from day) = ?', [$GetMonth])->whereIn("student_id",$FetchStudents)->where("present",false)->select("day",DB::raw('count(*) as absent'))->groupBy("day")->get();
Here I'm grouping data by day column because 1 day can have multiple records of present and absent.