Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assuming that you have a table named "attendance" with the following columns:

  • id (unique identifier)
  • employee_id (employee's unique identifier)
  • time_in (datetime when the employee clocks in)
  • time_out (datetime when the employee clocks out)

You can use the following query to generate a report on time in and time out:

SELECT employee_id, DATE(time_in) AS date, TIME(time_in) AS time_in, TIME(time_out) AS time_out
FROM attendance
WHERE time_out IS NOT NULL
ORDER BY employee_id, time_in

This query will get the employee ID, date, time in, and time out for each clock-in and clock-out event in the attendance table. The WHERE clause filters out any records where the time out is null, as those represent times when the employee is still clocked-in. The results will be sorted by employee ID and then by time in, so you can see each employee's clock-in and clock-out times in sequence.