to:tgbdlwm,<br>我试了一下,不知道哪里出错<br>s:=s+'select D.日期,iif((select sum(合计数量) from xiaoshourecord S where (S.日期 = D.日期) and (S.日期 between '''+s1+''' and '''+s2+'''))is null,0,(select sum(合计数量) from xiaoshourecord S where (S.日期 = D.日期) and (S.日期 between '''+s1+''' and '''+s2+'''))) as 销售合计数量 ';<br>s:=s+'from (select distinct 日期 from (select 日期 from xiaoshourecord where (日期 between '''+s1+''' and '''+s2+''') union all select 日期 from xiaoshouTHrecord where (日期 between '''+s1+''' and '''+s2+'''))) D';<br>以上在ACCESS可以,在SQL2000不知道怎么改才能运行