Quantcast
Channel: SCN : Popular Discussions - SAP Business One (Español)
Viewing all articles
Browse latest Browse all 677

Sumas por agrupaciones en crystal report

$
0
0

Buenas tardes estoy creando un reporte donde me da mis ventas,

 

esta es mi consulta

 

declare @i datetime, @f datetime

set @i=(/*select top 1 A.DocDate from OINV A where A.DocDate=*/'[%0]')   

set @f=(/*select top 1 A.DocDate from OINV A where A.DocDate=*/'[%1]')

SELECT T0.CardCode AS 'customer code',

T0.CardName AS 'Client name',CASE T0.DocType

When 'S'

then 'invoice service'

when 'I'

then 'Article invoice'

else 'NULL'

end AS 'Purchase Type',

CASE T0.U_TIPO_VENTA

When '1'

then 'invoice Injection'

when '2'

then 'Extrusion invoice'

else 'NULL'

end AS 'Purchase Type',

ISNULL(SUM(T0.doctotalfc)-SUM(T0.VatSumFC),0) as 'TOTAL SIN IVA',ISNULL(SUM(T0.VatSumFC),0) as 'IVA',ISNULL(SUM(T0.doctotalfc),0) as 'TOTAL FACTURA',

Isnull ((SELECT sum(X.DocTotalFC)-SUM(X.VatSumFC) FROM ORIN X WHERE X.Canceled='N' and X.CardCode = T0.CardCode and

/*T0.DocType = X.DocType and T0.U_TIPO_VENTA = X.U_TIPO_VENTA and*/ X.DocDate = T0.DocDate),0) As 'Credit notes',

ISNULL(SUM(T0.doctotalfc)-SUM(T0.VatSumFC),0)-ISNULL((SELECT sum(X.DocTotalFC)-SUM(X.VatSumFC) FROM ORIN X WHERE X.Canceled='N' and X.CardCode = T0.CardCode and

/*T0.DocType = X.DocType and T0.U_TIPO_VENTA = X.U_TIPO_VENTA and*/ X.DocDate = T0.DocDate),0)'TOTAL VENTA',

T0.DocCur,T0.DocDate

FROM OINV T0

WHERE T0.DocStatus = 'O' AND T0.SERIES = 4 and T0.DocDate between @i and @f

GROUP BY T0.CardCode,T0.CardName,T0.DocCur,T0.DocType,U_TIPO_VENTA,T0.DocDate,T0.DocStatus

ORDER BY T0.CardCode

FOR BROWSE

 

 

y mi crystal queda así

 

crystal01.jpg

crystal02.jpg

la consulta es como puedo hacer que al final tenga una suma de totales por agrupados por mis clientes, por mi tipo de articulo que vendí y por mi tipo de factura si fue de servicio o de artículos.


Viewing all articles
Browse latest Browse all 677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>