on 11-24-2010 3:39 PM
Muy buenas tardes estimados
El motivo del presente es que en la siguiente query
SELECT
T0.FatherNum,
(SELECT Y.AcctName FROM OACT Y WHERE Y.AcctCode = T0.FatherNum) 'Nombre Cuenta',
SUM(T1.Debit - T1.Credit) 'Saldo'
FROM OACT T0
INNER JOIN JDT1 T1 ON T1.Account = T0.AcctCode
WHERE T1.RefDate BETWEEN '[[%0]]' AND '[[%1]]'
GROUP BY T0.FatherNum
Las variables me arrojan un error que dice
"24/11/2010 12:16:59: 1). [[Microsoft]][[SQL Native Client]][[SQL Server]An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference."
Pero si las variables las cambio por
WHERE T1.RefDate BETWEEN '20100101' AND '20101031'
Funciona sin problemas, aunque la idea es poder darle el rango de fecha que el usuario desea. ya me habia pasado anteriormente con una query pero no me acuerdo que hice para corregirlo.
Atento a sus comentarios
Saludos
FLR
Edited by: Floyola on Nov 24, 2010 5:07 PM
Aqui lo tienes resuelto y espero tus puntos.
Saludos
Nelson Guerrero
SELECT T0.FatherNum,
(SELECT Y.AcctName FROM OACT Y WHERE Y.AcctCode = T0.FatherNum) 'Nombre Cuenta',
SUM(T1.Debit - T1.Credit) 'Saldo'
FROM OACT T0
INNER JOIN dbo.JDT1 T1 ON T1.Account = T0.AcctCode
WHERE T1.RefDate>='[%0]' and T1.RefDate<='[%1]'
GROUP BY T0.FatherNum
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.