local ldfirst,ldend,lcfishcode1,lcfischcode2 ldfirst=thisform.txtd1.value ldend=thisform.txtd2.value lcfischcode1=[001] && sales fische type lcfischcode2=[002] && sales fische type select sum(quantity*price)/sum(quantity) as navgpriceS from ??? where fischetype= m.lcfishcode1 and ; between(ldate,m.ldfirst,m.ldend) into cursor CrsSales select sum(quantity*price)/sum(quantity) as navgpriceB from ??? where fischetype= m.lcfishcode2 and ; between(ldate,m.ldfirst,m.ldend) into cursor CrsBuyings If _tally=0 select sum(quantity*price)/sum(quantity) as navgpriceB from ??? where fischetype= m.lcfishcode2 and ; m.ldfirst-ldate in (Select Min(m.ldfirst-ldate) from ??? where ldate<=m.ldfirst) into cursor CrsBuyings EndIfBy the way, actually avg(price) won't work, as it will not take into account the quantity.