与组的多列的总和
我有一个很大的复杂查询,带有40多列。查询的结果如下所示:
ItemCode | ItemName | CustomErcode | FAC1 | FAC1 | FAC2 | sum(FAC2) | FAC3 | SUM(FAC3) |
---|---|---|---|---|---|---|---|---|
001 | ABCD | 0023 0023 | DUMMY 1 | 0.25 | 0.25 0.25 | 0.75 0.75 | 0.1 | 0.5 |
001 | 0.2 0.2 0.2 0.2 0.5 001 ABCD | 002 | iabcd | ABCD abcd abcd abcd 0024 Dummy 2 0.25 | 0.25 | dyyy dyyy dyyy dyyy d.25 | dumm dyyy | 0.25 0.25 0.25 0.25 |
ABCD 002 ABCD 002 | ABCD | dyyy d.25 | dumm | 。 | 0.25 | 0.75 | 0.2 | 0.5 |
002 | efgh | 0023 | 假人1 | 0.20 | 0.52 0.52 | 0.1 | 0.1 | 0.1 |
003 | MNOP | 0023 | 假人1 | 0.50 | 0.50 0.75 | 1.25 | 1.25 | 0.3 0.7 |
003 | MNOP | 0024 0024 | 虚拟2 | 0.20 0.20 | 0.20 0.50 | 0.50 1.25 | 0.4 | 0.4 0.7 |
我想要单个值(IE fac lace列)和这些列的总和(IE fac lace列)上面的总和(FAC2))。这里的问题在于,总和应按itemCode组成,而不是所有值(也不包含客户代码)。我不介意以总和(FAC2)或总和(FAC3)列重复的总和值。提前致谢。
I have a big complex query with 40+ column. The result of the query look like this:
itemCode | itemName | customerCode | customerName | fac1 | fac2 | sum(fac2) | fac3 | sum(fac3) |
---|---|---|---|---|---|---|---|---|
001 | ABCD | 0023 | Dummy 1 | 0.25 | 0.25 | 0.75 | 0.1 | 0.5 |
001 | ABCD | 0024 | Dummy 2 | 0.25 | 0.25 | 0.75 | 0.2 | 0.5 |
001 | ABCD | 0025 | Dummy 3 | 0.50 | 0.25 | 0.75 | 0.2 | 0.5 |
002 | EFGH | 0023 | Dummy 1 | 0.20 | 0.52 | 0.52 | 0.1 | 0.1 |
003 | MNOP | 0023 | Dummy 1 | 0.50 | 0.75 | 1.25 | 0.3 | 0.7 |
003 | MNOP | 0024 | Dummy 2 | 0.20 | 0.50 | 1.25 | 0.4 | 0.7 |
I want the individual values (i.e fac columns) and SUM of some of these columns (like column sum(fac2) above). The problem here is that the sum should be group by itemCode and not with all values (not with customer code as well). I don't mind sum values repeated in sum(fac2) or sum(fac3) columns. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在下面得到了它:
I got it through below: