Skip to Content
0
May 24, 2011 at 04:39 PM

Report of total invoice per area

31 Views

Dear Experts,

I am trying to make a report using query generator. The report is total invoice per area but I am still failed. here is the query I made:

 elect distinct OTER.descript,
'invoice per teritory' = (select distinct sum(a.DocTotal) from oinv a inner join ocrd b on b.cardcode = a.CardCode where a.CardCode = OINV.CardCode and b.County = OCRD.County group by b.County) from INV1 inner join OINV on OINV.DocEntry =
INV1.DocEntry 
INNER JOIN OCRD on OCRD.CardCode=OINV.CardCode
	LEFT JOIN OTER on OTER.territryID=OCRD.Territory
where OINV.DocDate between '01/01/2010' and '01/28/2010'

The result is as follows:

Area A 47533700.000222

Area A 53663149.964662

Area B 772500.000010

Area B 6705000.000072

Area C 7890000.901213

It is not expected.

I am using query generator is :

Area A 101196850

Area B 7477500

Area C 7890000.901213

but my query still give unexpected result. Please advice. Thanks a lot.

steve