Código:
Como veran el parametro del cual depende la consulta es la fecha!!!...esa es mi variable. SELECT dbo.E1.CODE, dbo.E1.DIGITO, MSap_1.Medida, MSap_1.Linea, dbo.CAT_TRADE.EQUIPO, dbo.CAT_TRADE.SIDEWALL AS SIDEWALL, AVG (dbo.E1.WEIGHT) AS PPROM, dbo.E1PESO.PESO AS PESTAND, COUNT(dbo.E1.CODE) AS CANTIDAD, dbo.ES1.WAREHOUSE, MIN(dbo.E1.FECHC) AS FECHMIN FROM dbo.CAT_TRADE INNER JOIN dbo.E1 ON dbo.CAT_TRADE.DIGITO = dbo.E1.DIGITO LEFT OUTER JOIN dbo.E1PESO ON dbo.E1.CODE = dbo.E1PESO.CODE RIGHT OUTER JOIN [SERV-BCODE].Rast.dbo.opUnicos opUnicos_1 LEFT OUTER JOIN SERV_MONITOREO.Monitoreo.dbo.MSAP MSap_1 ON opUnicos_1.CodigoC = MSap_1.CodigoC ON dbo.E1.IDETIQ = opUnicos_1.IdEtiq WHERE (dbo.E1.FECHC >'03/09/2007 00:00') AND (dbo.E1.FECHC < ' 03/09/2007 23:59') GROUP BY dbo.E1.CODE, MSap_1.Medida, dbo.E1.WAREHOUSE, MSap_1.Linea, dbo.E1.DIGITO, dbo.CAT_TRADE.EQUIPO, dbo.CAT_TRADE.SIDEWALL, dbo.E1PESO.PESO HAVING (dbo.E1.CODE > '0') AND (dbo.E1.WAREHOUSE = 1) ORDER BY dbo.E1.CODE, dbo.E1.DIGITO, MSap_1.Medida, MSap_1.Linea