hi friends I am trying to calculate the arrears of the teachers ... making the query I get what I want but reviewing the data I get in some fields with null values. Here the consultation:
SELECT th.codigopersonal, tp.nombres, tr.fecha, th.dia, th.j_codigo,
th.hora_entrada, th.hora_salida, tr.hora_entra,
tr.hora_sale,th.numero_horas, sec_to_time((time_to_sec (IF((tr.hora_entra >
th.hora_entrada), (tr.hora_entra - th.hora_entrada),0))))as AtrEntrada,
SEC_TO_TIME((time_to_sec(IF(tr.hora_sale < th.hora_salida, th.hora_salida-
tr.hora_sale,0))))as AtrSalida
from tb_horarios as th
left JOIN tb_registroasistencia as tr ON th.codigopersonal=tr.psn_codigo AND
th.dia= tr.dia AND th.j_codigo=tr.jnd_codigo
LEFT JOIN tb_personal_org as tp ON th.codigopersonal= tp.codigo
WHERE tr.fecha BETWEEN '2018-02-12' AND '2018-02-16'
GROUP BY th.codigopersonal, tr.fecha
ORDER BY 'tp'.'nombres' ASC
Here are the results of the query:
I hope you can help me!