Ver Mensaje Individual
  #6 (permalink)  
Antiguo 10/01/2011, 12:10
jurena
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Cáceres
Mensajes: 3.735
Antigüedad: 16 años, 1 mes
Puntos: 300
Respuesta: Revisar mes a mes dentro de un rango

No he probado esto, y tampoco sé si te falseará datos, en tu intento de contar los diferentes de cada tabla, aunque sean coincidentes en las dos tablas.
Mira a ver si esto te da algo:

SELECT COUNT(DISTINCT tnum) tnum, MONTHNAME(astart), YEAR(astart) FROM ((SELECT tnum, astart
FROM multi
WHERE rkey IN
(SELECT num
FROM worder
WHERE astart >= rango_fecha
AND astart < rango_fecha
AND STATUS IN ('COMP','CLOSE')
AND istsk = 0
AND substring(location,1,1)='E')
)
UNION ALL
(SELECT tnum, astart FROM worder WHERE astart >= rango_fecha AND astart < rango_fecha AND STATUS IN ('COMP','CLOSE') AND istsk = 0 AND substring(location,1,1)='E' AND num NOT IN (SELECT rkey FROM multi WHERE reclass='WORKORDER') )) GROUP BY YEAR(astart), MONTH(astart)