SQLServer2008 关于数值字段列的累计
create table #temp20110610
(
id int identity(1,1),
date varchar(8),
qty float
)
insert into #temp20110610
select '20110401',40 union all
select '20110402',64 union all
select '20110403',56 union all
select '20110404',346 union all
select '20110405',56 union all
select '20110406',678 union all
select '20110407',1234 union all
select '20110408',560 union all
select '20110409',460 union all
select '20110410',566 union all
select '20110411',344 union all
select '20110412',77 union all
select '20110413',90
declare @SDate varchar(8),@EDate varchar(8),@conditionQty float
set @SDate='20110405'
set @EDate='20110411'
set @conditionQty=3000
--得到指定日期范围类,Qty列的累积数量大于3000
select id,date,qty,
(select SUM(qty) from #temp20110610 where date<=A.date and date between @SDate and @EDate) Qty累计量
from #temp20110610 A
where (select SUM(qty) from #temp20110610 where date<=A.date and date between @SDate and @EDate)<=@conditionQty
and date between @SDate and @EDate
order by A.date
最新文章
- 用php实现一个简单的链式操作
- Python学习笔记(四)字符串型
- 回忆读windows 核心编程
- [PHP100] PHP如何防止注入及开发安全
- SAP传输系统TMS、开发类、传输请求
- 【C++基础】关键字static 局部变量
- Android studio中找不到so文件的问题:java.lang.UnsatisfiedLinkError
- JavaScript系列----事件机制
- salesforce零基础学习(八十二)审批邮件获取最终审批人和审批意见
- Kudu存储实战笔记
- 以太坊ERC20代币开发
- C# ADO.NET的SqlDataReader对象,判断是否包含指定字段
- day5 笔记
- centos U盘挂载问题
- static之静态初始化块
- FF笔试题整理
- Linux 压缩解压缩命令详解
- 20145330 《网络攻防》 MSF基础应用
- RepositionBars的用法和参数的意义(引用别人的)
- Citrix服务器虚拟化之二十九 XenApp 6.5发布服务器上的应用程序
热门文章
- btrfs基础
- asp网站中使用百度ueditor教程.txt
- webpack打包出错,通过babel将es6转es5的出错。
- BZOJ 1631 Usaco 2007 Feb. Cow Party
- 公钥基本结构(PKI)的概念
- ActiveMQ学习总结(10)——ActiveMQ采用Spring注解方式发送和监听
- hdu6096 String
- Master Nginx(8) - Troubleshooting Techniques
- [bzoj4385][POI2015]Wilcze doły_单调队列
- HDU 4542