作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的问题..
Actual Auction Ammanat id
7000 500 100 228,229
7000 100 100 228,229
7000 900 100 228,229
5000 0 0 230
我想要下面给出的结果
Actual Auction Ammanat Remaining id
7000 500 100 5550 228,229
7000 100 100 5550 228,229
7000 900 100 5550 228,229
5000 0 0 5000 230
这里,剩余
是(sum(auction)-actual)
。
我正在使用 PostgreSQL。但是,如果有人知道 SQL Server 中的解决方案,那就没问题了。
最佳答案
您需要使用窗口函数 - http://www.postgresql.org/docs/9.3/static/tutorial-window.html
类似于:
(Sum(Auction) OVER ()) - actual AS Remaining
关于sql - 如何在没有分组依据的情况下进行求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19271646/
我是一名优秀的程序员,十分优秀!