I want to get attendance, absences, lateness, and lateness (one absent out of three) from MySQL. I'd like to count the number of absences for being late (three times and one time) as one absence for being late every month.
I want to calculate attendance based on the following conditions, but I don't know how to write it
"I created a query to aggregate attendance below, but I don't understand the description that incorporates the condition ""91.6% if HR is absent only""""
This is the answer to your question what you don't understand.
Because HR is treated specifically in the calculation of attendance conditions, it will be conditional branching such as case statement.
What you want to doMonthly processing in one SQL can be too complicated to maintain, so we recommend using a temporary table or program to calculate the monthly processing.
The following is an example of SQL calculation of attendance.
Count HR attendance and regular class attendance in the with clause, and find attendance by conditional branching in the case statement of select.
lectures table contains one day's worth of lectures and assumes that
lectures.name='HR' is HR.
Use the with clause to run
MySQL 8.0 or higher.
© 2022 OneMinuteCode. All rights reserved.