不好意思,前面的有点粗心.这个我测试过了.
select 1,tb1.startdate,tb1.enddate,sum(tb1.num) from TestNum tb1 , (select id ,startdate,enddate,num from TestNum where id='1')tb2
where tb1.startdate=tb2.startdate and tb1.enddate=tb2.enddate
group by tb1.startdate,tb1.enddate
select 1,tb1.startdate,tb1.enddate,sum(tb1.num) from TestNum tb1 , (select id ,startdate,enddate,num from TestNum where id='1')tb2
where tb1.startdate=tb2.startdate and tb1.enddate=tb2.enddate
group by tb1.startdate,tb1.enddate