低手回复 
你的表的日期字段有吗
select 客户名称,货物名称,提货数量,
(select sum(提货数量) from Dispatch where 客户名称=a.客户名称 and 月=本月)
from Dispatch as a

解决方案 »

  1.   

    谢谢!日期字段是有的,只是会计月有可能跨月,例如7.26-8.26,客户名称是基本固定的,不知数据感知用TDBgrid,还是TstringGrid.
      

  2.   

    放俩个DateTimePicker(一个是统计起始日子,另一个是统计结束日期)select sum(提货数量)
    from TableName
    where 客户名称='****'
    and Year(日期)>=Year(DateTimePicker1.Date)
    and Month(日期)>=Month(DateTimePicker1.Date)
    and Year(日期)<=Year(DateTimePicker2.Date)
    and Month(日期)<=Month(DateTimePicker2.Date)
    在Access中,不知道是否也象SqL Server一样 用Year,Month函数,你参看一下资料.只是低手的回复,未通过高手的验证和测试。