on 07-17-2012 9:44 PM
Jovenes expertos, tengo el siguiente problemita necesito que me realice una sumatoria de facturas de proveedores en base a un items tengo una query ya realizada pero no me esta haciendo la sumatoria del item sino que me despliega es si existe en tres facturas coloca 3 lineas con el valor de cada items,
el query es el siguiente:
Select Distinct T0.CardCode, max(T0.CardName) [Nombre],
CASE When month(T1.DocDate)= '01' and T1.ItemCode= 'PLA0001' Then SUM(T1.Gtotal) end as 'Total Enero'
From OPCH T0 INNER JOIN
PCH1 T1 ON T0.DocEntry = T1.DocEntry
Where T0.DocDate>='20120101' and T0.Docdate<='20120630' and T0.U_operado = 'N'
Group By T0.CardCode,T1.ItemCode, T0.CardName, T1.GTotal, T0.DocDate,T1.DocDate
Order By T0.CardCode
De antemano agradezco su ayuda y su tiempo.
Saludos
Hola
SELECT DISTINCT T0.CardCode, T0.CardName,
ISNULL((SELECT SUM(Y.Gtotal) FROM PCH1 Y INNER JOIN OPCH X ON X.DocEntry=Y.DocEntry WHERE X.CardCode=T0.CardCode AND Y.ItemCode='PLA0001' AND MONTH(X.DocDate)=1 AND X.U_operado='N'),0)
FROM OPCH T0
Pruebalo asi
Slds
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
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.