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)
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)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货