Ver originalselect * from empresa.empleado e inner join empresa.departamento d on e.iddept = d.iddeptgroup by d.iddepthaving ;