on 04-07-2016 6:52 PM
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í
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.
Hola Antonio.
En primer lugar debes tener creado tus grupos en crystal reports.
Una vez creados tus grupos, creas campos de totales acumulados poniendo total atención en el campo que te señalo a continuación:
De esta manera podrás crear un campo para cada total de grupo, cambiándole el grupo a evaluar.
Suerte.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No es necesario los grupos puedes indicar que cambie cuando cambia un campo, esto sirve para cuando las usaras en graficos, inclusive agregar con una formula un criterio para que se sume solo los valores que necesites, los grupos son utiles cuando separas los datos, si quieres al final de todo el reporte los totales es mejor la suma con formula una para cada cliente eso es lo unico tedioso
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 | |
11 | |
10 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.