with c as (select a.trandt,sum(a.tranam) tranam from tran a group by a.trandt )--将子查询抽取出来,以后可以直接用。该方法只适用于oracle,mysql不支持 select c.trandt, sum(d.tranam) from c inner join c d on c.trandt >= d.trandt group by c.trandt select c.trandt, sum(d.tranam) from (select a.trandt, sum(a.tranam) tranam from tran a group by a.trandt order by a.trandt) c inner join (select a.trandt, sum(a.tranam) tranam from tran a group by a.trandt order by a.trandt) d on c.trandt >= d.trandt group by c.trandt
原文地址:https://www.cnblogs.com/wanjn/p/11082691.html
时间: 2024-11-03 17:01:57