作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个必须运行总计的场景,我可以通过纯 T-SQL 或脚本任务来实现这一点。但我想避免手动编码,并使用 ETL 工具功能。是否可能以及如何。
我有表余额
SELECT '00000001' AS [AccountNo], CONVERT(date,'20080828') AS [Date],10 AS [DailyMovement]
INTO balances
UNION ALL
SELECT '00000001' AS [AccountNo], CONVERT(date,'20080829') AS [Date],5 AS [DailyMovement]
UNION ALL
SELECT '00000001' AS [AccountNo], CONVERT(date,'20080830') AS [Date],7 AS [DailyMovement]
UNION ALL
SELECT '00000002' AS [AccountNo], CONVERT(date,'20080828') AS [Date],8 AS [DailyMovement]
UNION ALL
SELECT '00000002' AS [AccountNo], CONVERT(date,'20080829') AS [Date],6 AS [DailyMovement]
SELECT b1.[AccountNo]
, b1.[Date]
, b1.[DailyMovement]
, SUM(b2.[DailyMovement]) AS [RunningTotal]
FROM balances b1
INNER JOIN balances b2 ON b1.[AccountNo] = b2.[AccountNo]
AND b1.[Date] >= b2.[Date]
GROUP BY b1.[AccountNo],b1.[Date],b1.[DailyMovement];
最佳答案
您是否尝试添加查询
SELECT b1.[AccountNo]
, b1.[Date]
, b1.[DailyMovement]
, SUM(b2.[DailyMovement]) AS [RunningTotal]
FROM balances b1
INNER JOIN balances b2 ON b1.[AccountNo] = b2.[AccountNo]
AND b1.[Date] >= b2.[Date]
GROUP BY b1.[AccountNo],b1.[Date],b1.[DailyMovement];
关于ssis - 可以在 SSIS 中实现运行总和,而无需任何手动编码吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10798177/
我是一名优秀的程序员,十分优秀!