第二题答案 select b.month "月份",
b.mon_amount "当月销售金额",
sum(b.mon_amount)over(partition by b.year order by b.month) "累计销售金额"
from
(select a.month,a.year,sum(a.amount) as mon_amount
from
(select id,user_id,paid_time,substr(paid_time,1,7) as month,
substr(paid_time,1,4) as year,amount
from order_record
order by paid_time) a
group by a.month,a.year
order by a.month) b