on 12-22-2011 3:55 PM
buenos dias foro
Tengo una duda con el siguiente query
les explico brevemente que hace, me arroja lo que esta pendiente por facturar en base a las ordenes de venta aqui lo filtro
por solo lo que esta abierto, que no me traiga las OV cuando digan comprometido y por un cliente en particular que es el
unico al que se le vende por consignacion, funciona muy bien pero cuando una OV esta parcialmente abierta me arroja toda la
cantidad y necesitaria que me arrojara solo lo que se quedo pendiente de facturar, alguien sabria como hacerlo
Aprovecho para deserarles felices fiestas
Gracias
Select ORDR.CardName As Cliente, Sum(ORDR.DocTotal - ORDR.VatSum) As
[Total por Facturar]
From ORDR
Where ORDR.DocStatus = 'O' And Not (ORDR.NumAtCard = N'comprometido')
Group By ORDR.CardName
Having Not (ORDR.CardName = N'FARMACIA GUADALAJARA, S.A. DE C.V.') And
Sum(ORDR.DocTotal - ORDR.VatSum) > .01
Order By [Total por Facturar] Desc
Hola
Intenta con INNER JOIN y agregar en vez de docstatus, el linestatus que son las lineas del detalle
Select T0.CardName As Cliente, Sum(T0.DocTotal - T0.VatSum) As
Total por Facturar
From ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
Where T1.LineStatus = 'O' And Not (T0.NumAtCard = N'comprometido')
Group By T0.CardName
Having Not (T0.CardName = N'FARMACIA GUADALAJARA, S.A. DE C.V.') And
Sum(T0.DocTotal - T0.VatSum) > .01
Order By Total por Facturar Desc
Saludos,
Sara
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.