在查找可用数量总和时遇到问题 [英] Getting problem to find Sum of Available Quantity
问题描述
我通过Query获得了SQL组中的下表值.
我需要找出可用数量.
例如,
6715(Groupby)识别的总数量= 10
6715(Groupby)识别的总和= 2 + 2 +2 =6.
我想要结果总数量– TotalSumQty10 – 6 = 4(可用数量).
我只是想获取可用数量.请帮忙.
查看我的查询:
Hi,
I have the below table values from the SQL group by Query.
I need to find out the Available Quantity.
For Example,
Total Qty = 10 for the 6715 (Groupby) Identification
Total Sum Qty = 2 + 2 +2 = 6 for the 6715 (Groupby) Identification.
I want the result Total Qty – TotalSumQty 10 – 6 = 4 (Available Qty).
Just I want to get the Available Qty. Please Help.
See my Query:
select
unit,
Number,
L.identification as identification,
RequiredQty,
sum(RequiredQty) as TotalSumQty,
I.TotalQty,
(I.TotalQty – I.RequiredQty) as AvailableQty,
convert(varchar,AvailabilityDate,101) as AvailabilityDate
from
tbl1 L
INNER JOIN
Tbl2 I
on
L. identification = I. identification
WHERE gi.ident='6715'
group by Number, unit,L. identification,requiredQty,I.TotalQty,AvailabilityDate
unit Number Identification RequiredQty TotalSumQty TotalQty AvailableQty
1-GD-B-08225 AB-00009-S10B-1 6715 1 2 10 ?
2-GD-B-08275 AB-00009-S10B-1 6715 1 2 ?
3-GD-B-08324 AB-00009-S10B-1 6715 1 2 ?
推荐答案
尝试使用
Try using
sum(I.TotalQty – I.RequiredQty) as AvailableQty,
代替
instead of
(I.TotalQty – I.RequiredQty) as AvailableQty,
如果这不能解决您的问题,请发布tbl1&的表结构tbl2.
if this does not solve your issue then please post the table structure of tbl1 & tbl2.
这篇关于在查找可用数量总和时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!