select identity(int,1,1) id,* into # from 表select max(日期),max(单号),sum(A1),sum(B1),sum(C1) 
from # t 
where id in(select top 2 id 
                from # 
                     where 日期=t.日期 
                           and 单号=t.单号 
                         order by id)
union all
select select 日期,单号,A1,B1,C1 from # t
where id not in(select top 2 id 
                   from # 
                     where 日期=t.日期 
                           and 单号=t.单号 
                         order by id)