Buen día para todos,
Tengo un informe el cual me muestra la cantidad facturada del día y el acumulado del mes por cada empleado de ventas.
SELECT DISTINCT T1.[SlpCode], T1.[SlpName],
ISNULL((SELECT SUM(T.[DocTotal]-T.[Vatsum]) FROM OINV T WHERE
YEAR(T.[DocDate]) = YEAR(T0.[DocDate]) AND
MONTH(T.[DocDate]) = MONTH(T0.[DocDate]) AND
DAY(T.[DocDate]) = DAY(T0.[DocDate]) AND T.[SlpCode] = T1.[SlpCode]),0)
-ISNULL((SELECT SUM(Y.[DocTotal]-Y.[Vatsum]) FROM ORIN Y WHERE
YEAR(Y.[DocDate]) = YEAR(T0.[DocDate]) AND
MONTH(Y.[DocDate]) = MONTH(T0.[DocDate]) AND
DAY(Y.[DocDate]) = DAY(T0.[DocDate]) AND
Y.[SlpCode] = T1.[SlpCode]),0) AS 'Facturado Hoy',
ISNULL((SELECT SUM(T.[DocTotal]-T.[Vatsum]) FROM OINV T WHERE
YEAR(T.[DocDate]) = YEAR(T0.[DocDate]) AND
MONTH(T.[DocDate]) = MONTH(T0.[DocDate]) AND T.[SlpCode] = T1.[SlpCode]),0)
-ISNULL((SELECT SUM(Y.[DocTotal]-Y.[Vatsum]) FROM ORIN Y WHERE
YEAR(Y.[DocDate]) = YEAR(T0.[DocDate]) AND
MONTH(Y.[DocDate]) = MONTH(T0.[DocDate]) AND Y.[SlpCode] = T1.[SlpCode]),0) AS 'Acumulado del Mes'
FROM OINV T0
INNER JOIN OSLP T1 ON T0.[SlpCode] = T1.[SlpCode]
WHERE DAY(T0.[DocDate]) = DAY(GETDATE()) AND MONTH(T0.[DocDate]) = MONTH(GETDATE()) AND YEAR(T0.[DocDate]) = YEAR(GETDATE())
ORDER BY T1.[SlpCode]
Se me solicitó que este informe le llegue todos los días a cada empleado de ventas al correo electrónico, pero que no aparezca el informe general, que se discrimine por cada empleado de ventas.
¿Qué condición debo poner en el WHERE para que a cada empleado de ventas solo le llegue su acumulado diario y mensual?
Muchas gracias.