回答

收藏

如何不按分组方式求和

技术问答 技术问答 548 人阅读 | 0 人回复 | 2023-09-14

这是我的问题。! j, E' {" j. q6 `; x5 s, D
Actual   Auction   Ammanat   id7000    500       1000      228,2297000         100        228,2297000          228,2295000                        我想要以下结果
4 V2 B. d3 w& a! N* vActual   Auction   Ammanat   Remaining  id5000            5550      228,2297000          5550         228,2297000           550     550     228,2297000         550      5550                            在这里Remaining是(sum(auction)-actual)。
0 ]/ }  \- Y1 B1 Q我正在使用PostgreSQL。但是,如果有人知道的话SQL Server解决方案,那就可以了。# W; j8 q2 H8 G$ C
                                                                3 t+ |5 d- d3 {3 i( I4 Z+ ?
    解决方案:                                                                ; d$ {4 Q7 c0 P+ z: ?/ d! T' }
                                                                您需要使用窗口功能-http://www.postgresql.org/docs/9.3/static/tutorial-
6 p; x5 x. k& w7 t' Lwindow.html3 F. x1 W( N) q( K  Z
就像是:4 z% m5 ~2 P8 m6 c
(Sum(Auction) OVER ()) - actual AS Remaining
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则