年少才敢轻狂 发表于 2023-9-14 12:26:35

如何不按分组方式求和

这是我的问题。
Actual   Auction   Ammanat   id7000    500       1000      228,2297000         100      228,2297000          228,2295000                        我想要以下结果
Actual   Auction   Ammanat   Remainingid5000            5550      228,2297000          5550         228,2297000         550   550   228,2297000         550      5550                            在这里Remaining是(sum(auction)-actual)。
我正在使用PostgreSQL。但是,如果有人知道的话SQL Server解决方案,那就可以了。
                                                               
    解决方案:                                                               
                                                                您需要使用窗口功能-http://www.postgresql.org/docs/9.3/static/tutorial-
window.html
就像是:
(Sum(Auction) OVER ()) - actual AS Remaining
页: [1]
查看完整版本: 如何不按分组方式求和