Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Need to sum the Doc total

Hi experts

i had created a query with OIN,INV1 AND UDT with Hedder and Row level

it working fine, but now i need to sum and get total figure of the OINV.DocTotal

but when am using sum(OINV.Doctotal) am getting a different value

pls find the attache query and help me to solve this

-----------------------------------------------------------------------------------------------------------------------------

Query:

select distinct oinv.doctotal,[@BP_CONT_F1].U_ContValue AS 'Contract value',oinv.u_documentType as 'Document Type' from oinv

inner join inv1 on oinv.docentry = inv1.docentry

inner join [@BP_CONTVALUE_YR_H] on oinv.cardcode = [@BP_CONTVALUE_YR_H].u_bpcode

inner join [@BP_CONT_F1] on [@BP_CONTVALUE_YR_H].docentry=[@BP_CONT_F1].docentry

where oinv.cardname = 'ABB-Contracting Co.Ltd'

and oinv.docdate between '2015-01-01 00:00:00.000' and '2015-01-31 00:00:00.000'

and  oinv.u_documentType = 001

group by oinv.doctotal,[@BP_CONT_F1].U_ContValue ,oinv.u_documentType

-----------------------------------------------------------------------------------------------------------------------------------------

Query Return :

doctotalContract valueDocument Type
12567.0000002000000.0000000001
14154.0000002000000.0000000001
29846.0000002000000.0000000001
232662.0000002000000.0000000001

i need it in this format :

doctotalContract valueDocument Type
28922920000000001

Regards

Former Member
replied

Could be due to INV1. Could you please try without that table:

select SUM(oinv.doctotal) AS TotalDocTotal,[@BP_CONT_F1].U_ContValue AS 'Contract value',oinv.u_documentType as 'Document Type' from oinv

inner join ( [@BP_CONTVALUE_YR_H] on oinv.cardcode = [@BP_CONTVALUE_YR_H].u_bpcode

inner join [@BP_CONT_F1] on [@BP_CONTVALUE_YR_H].docentry=[@BP_CONT_F1].docentry

where oinv.cardname = 'ABB-Contracting Co.Ltd'

and oinv.docdate between '2015-01-01 00:00:00.000' and '2015-01-31 00:00:00.000'

and  oinv.u_documentType = 001

group by [@BP_CONT_F1].U_ContValue ,oinv.u_documentType

Regards,

Johan

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question