--创建测试临时表

If OBJECT_ID('tempdb..#temp') is not null drop table #temp

Create table #temp(
MyDate date,
OrderNums int

)

--插入测试数据

insert into #temp values ('2017-09-01',1),('2017-09-02',2),('2017-09-03',3),('2017-09-04',4)


--查询

select adate,sum(OrderNums) from(
select a.MyDate adate,b.MyDate bdate,b.OrderNums

 from #temp a left join #temp b on b.MyDate<=a.MyDate) b group by adate



 sql 日累计,不对等关联

相关文章:

  • 2021-11-30
  • 2021-11-30
  • 2021-11-13
  • 2021-05-04
  • 2022-01-26
  • 2022-12-23
  • 2021-06-16
猜你喜欢
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-11-14
  • 2021-12-21
  • 2022-12-23
相关资源
相似解决方案