Hi Experts,
Im Using Ms-access 2007
I want to subtract Two fields in the query
and my query is
select A.FC,A.RC,A.TotalAmount,A.CansBalance,A.ShopNo,A.A rea,A.SalesType,B.TotalCustomers,C.TotalUndelivere d ,
(CInt(B.TotalCustomers) - CInt([C.TotalUndelivered])) as TotalDelivered from
( (SELECT sum(CardCust_Trans.FC) as FC, sum(CardCust_Trans.RC) as RC, sum(CardCust_Trans.Tot_Amt) as TotalAmount,sum(Balance_Cans) as CansBalance,ShopNo,Area,'CUSTOMERSALES' AS SALESTYPE FROM CardCust_Trans WHERE(CardCust_Trans.Trans_Date >=#12/1/2012# And CardCust_Trans.Trans_Date <= #12/8/2012#) group by ShopNo,Area order by ShopNo ) as A
inner join
(select count(*) as TotalCustomers ,ShopNo,Area from Customer_Master group by ShopNo,Area) as B on A.ShopNo=B.ShopNo and A.Area=B.Area )
left join
(select CInt(IIF(isnull(count(*)),0,count(*))) as TotalUndelivered ,ShopNo,Area from CardCust_Trans where Trans_Date >= #12/1/2012# and Trans_Date<= #12/8/2012# and FC=0 group by ShopNo,Area) as C on A.ShopNo=C.ShopNo and A.Area=C.Area
and the result of abover query is something like this
198 198 792 0 Shop No 8 No COUTERSALES 3 0 0 145 65 1450 80 Shop No 7 No FUNCTIONSALES 4 0 0 242 242 1936 409 Shop No 6 Area 2 CUSTOMERSALES 104 31 73
Here im Subtracting column8 - column 9 and i want to get the result in column9
But still im getting 0 values in the last column
it should be 3-0=3 and 4-0=4
and im getting the correct result if there is any number other than 0 in column8 and column9
Any Help Would be greatly appreciated
Thanks
Shafi