select *From (
select t1.月份,t1.类别, sum(t2.Revenue) as sumN
from Revenue as t1, Revenue as t2
where 1=1 and t1.类别='Products' and t1.id>=t2.id
group by t1.类别,t1.月份
union
select aa.月份,aa.类别, sum(bb.Revenue) as sumN From(
select *From Revenue where 类别='Services'
)aa,
(
select *From Revenue where 类别='Services'
)bb where aa.id>=bb.id
group by aa.类别,aa.月份
)aaa
group by aaa.类别,aaa.月份
order by aaa.类别,cast(aaa.月份 as int)