在同一个表上创建更新总计查询很困难
考虑下表:
ID nonUniqueID value total
--------------------------
1 12345 5 x
2 12345 10 x
3 789 20 x
4 789 5 x
我需要进行类似这样的查询(伪 SQL),它将在 Access 2007 中工作:
UPDATE table
SET total = SUM(value)
WHERE nonUniqueID IS SAME;
结果应该如下:
ID nonUniqueID value total
--------------------------
1 12345 5 15
2 12345 10 15
3 789 20 25
4 789 5 25
我已经尝试过分组依据,但我得到了奇怪的结果,坦率地说,我无法解释。有谁知道我怎样才能实现这样的目标?
Consider the following table:
ID nonUniqueID value total
--------------------------
1 12345 5 x
2 12345 10 x
3 789 20 x
4 789 5 x
I need to make a query something like this (psuedo SQL), which will work within Access 2007:
UPDATE table
SET total = SUM(value)
WHERE nonUniqueID IS SAME;
The result should be as follows:
ID nonUniqueID value total
--------------------------
1 12345 5 15
2 12345 10 15
3 789 20 25
4 789 5 25
I've tried group bys, but I got odd results that quite frankly, I could not interpret. Does anybody know how I could achieve something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这在 Access 中是否有效,但请尝试一下:
更新:基于 这个问题,看起来行不通。但试一试吧!如果没有,您可以使用该问题中建议的方法。
Not sure if this works in Access or not, but give it a try:
Update: Based on this question, it looks like it is not going to work. But give it a shot! If it doesn't, you can use the approach suggested in that question.
另一种可能的选择:
Another possible option: