optimizacion query
Amigos
Existe alguna otra forma de rescribir esta query, se necesita todos los campos de la tabla.
select *
from planillas AS PLAN1
WHERE PLAN1.PERIODO='201403'
and PLAN1.RUT_TRABAJADOR is not null
and PLAN1.RUT_EMPLEADOR is not null
and (SELECT count(distinct rut_empleador) FROM planillas
where plan1.rut_trabajador = plan2.rut_trabajador and plan2.periodo = plan1.periodo and PLAN1.RUT_EMPLEADOR <> PLAN2.RUT_EMPLEADOR) = 0;
- Inicie sesión o regístrese para enviar comentarios
plan2
no está definido plan2 en ningún lado