如何计算购买和销售数量的差异? [英] How to calculate difference of purchase and Sale Quantity?

查看:155
本文介绍了如何计算购买和销售数量的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Ms Access数据库在一个查询中计算购买和销售数量的差异?



对于Ex:

ProductId类型数量

1购买20

1促销10



如何获得(20-10 = 10)的差异在一个查询?

How to calculate difference of purchase and Sale quantity in One Query Using Ms Access Database?

For Ex:
ProductId Type Quantity
1 Purchase 20
1 Sale 10

How to get difference of (20-10=10)in one Query?

推荐答案

这样的事情:

Something like this:
SELECT P1.ProductId, (P1.Quantity - P2.Quantity) FROM MyProds as P1 INNER JOIN  MyProds as P2 ON P1.ProductId=P2.ProductId WHERE P1.Type='Purchase' AND P2.Type='Sale';



应该可以解决问题。


should do the trick.


这篇关于如何计算购买和销售数量的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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