1
I’m trying to generate a ranking of absences for HR.
The record of absences is made in a separate table of the Employee’s registration. I need to bring the list of active employees and the amount of absences he has had in the company, only I want to order the employee who had more absences for what had less.
I made the SQL below, but brings only the employees who had missed:
select rh.NOME_FUNCIONARIO, COUNT(registro_faltas_atraso.CPF) as Total from RH
JOIN registro_faltas_atraso
on registro_faltas_atraso.CPF =rh.cpf
where
rh.TIPO_CONTRATO !='Dispensado'
GROUP BY rh.NOME_FUNCIONARIO
ORDER BY desc total
use LEFT JOIN which will bring all records from the first table, in case Rh
– Ademilson Santana da Silva