访问查询中的减法 [英] Subtraction in Access Queries

查看:64
本文介绍了访问查询中的减法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,如果我有点傻,但我很困惑。


目前我的查询有3个字段。


一个人有一个产品ID号


下一个已购买数量


(表格中的这两个字段)

下一个已售出数量。现在,通过将具有给定产品ID号的所有记录相加来制作这个。获得销售数量。 ID编号的每次发生率都会增加1。


到目前为止一切顺利。我有产品ID'购买的数量和销售数量。


我现在还有一个领域将从数量中减去销售数量(在上一个查询字段中)购买以获得剩余数量。


如果有人可以帮助它将非常感激。

Hi sorry if I am being a bit dumb but i am confused.

Currently I have a query which has 3 fields.

One has a product ID number

The next has Quantity purchased

(these both fields from tables)

The next has quantity sold. Now this one is made by adding up all the records with a given "product ID number" to get the quantity sold. Each incidence of the ID number adds 1 to the total.

So far so good. I have product ID''s the quantity purchased and quantity sold.

I now what a further field that will substract the quantity sold(which is in the previous query field) from the quantity purchased to obtain quantity remaining.

If anyone could help it would be immensely appreciated.

推荐答案

从你的帖子我是认为您正在使用总计查询,因此您的结果可能不是您所期望的。我并不确定我理解但是在设计视图中查看查询的标准访问查询中,您可以在下半部分查看字段。如果你添加以下内容:MyRemQuant:[购买数量] - [销售数量]


我希望这有帮助,如果没有请发表您的SQL语句,以便我能更好地理解。
From your post I am thinking that you are using a totals query so your results may not be what you expect. I am not real sure I understand but In a standard access query looking at the query in design view you have the fields to be viewed in the lower portion. If you add the following: MyRemQuant:[quantity purchased]-[quantity sold]

I hope this helps if not please post your SQL statement so I can understand a little better.


SELECT SW_INFO.SWI_ID,CST.CST_QTY,Sum(SW_SLS.SWS_QTY)AS SumOfSWS_QTY

FROM(CST INNER JOIN SW_INFO ON CST.CST_ID = SW_INFO.SWI_CST_ID)INNER JOIN SW_SLS ON SW_INFO.SWI_ID = SW_SLS.SWS_SW_ID

GROUP BY SW_INFO.SWI_ID,CST.CST_QTY;



那就是我目前拥有的SQL 。


我想做的是有一个我可以减去的字段:

" Sum(SW_SLS.SWS_QTY)AS SumOfSWS_QTY"


来自

" CST.CST_QTY"
SELECT SW_INFO.SWI_ID, CST.CST_QTY, Sum(SW_SLS.SWS_QTY) AS SumOfSWS_QTY
FROM (CST INNER JOIN SW_INFO ON CST.CST_ID = SW_INFO.SWI_CST_ID) INNER JOIN SW_SLS ON SW_INFO.SWI_ID = SW_SLS.SWS_SW_ID
GROUP BY SW_INFO.SWI_ID, CST.CST_QTY;


Thats the SQL i have currently.

What i want to do is have a field where i can substract:
"Sum(SW_SLS.SWS_QTY) AS SumOfSWS_QTY"

From
"CST.CST_QTY"


"如果您添加以下内容:MyRemQuant:[已购买数量] - [已售出数量]"


我会在哪里添加此内容?只需在字段框中?
" If you add the following: MyRemQuant:[quantity purchased]-[quantity sold]"

Where would i add this? Simply in the field box?


这篇关于访问查询中的减法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆