MS Access - 如何根据另一个字段从一个字段中删除某些值?

时间:2015-06-16 17:05:08

标签: sql ms-access

我有2个字段的查询:tqtyComments。此查询用于通过执行计算“需求” - “库存”(伪代码)来生成我们需要传输材料的程度。

当填充时,当前数据如下所示:

tqty              Comments
0                Please check manually
100
200
300
0                Please check manually
0
0

您会注意到底部的2个零没有“请手动检查”这一短语。这是因为当查询执行计算((([qty_on_hand]-[qty_req])/[qty_req])<=0.2)时,该值不小于或等于0.2。 这是正常的。有些值会有这个。 但是我想删除tqtyComments下没有此词组的零。我该怎么做呢?

我想要查询的内容

tqty              Comments
0                Please check manually
100
200
300
0                Please check manually


SELECT 
qry_BENJobItems.item,
dbo_item.description, 
IIf(([qty_req]-[qty_on_hand])<0,0,([qty_req]-[qty_on_hand])) AS tqty,
"" AS [Transfer Pallets], 
"" AS Location, 
"" AS [Lot Code], 
dbo_item.product_code, 
Switch(((IIf(([qty_req]-[qty_on_hand])<0,0,([qty_req]-[qty_on_hand])))=0) And ((([qty_on_hand]-[qty_req])/[qty_req])<=0.2),"Please check manually") AS Comments

FROM (qry_BENJobItems INNER JOIN qry_BENInventory ON qry_BENJobItems.Item = qry_BENInventory.Item) INNER JOIN dbo_item ON qry_BENJobItems.Item = dbo_item.Item

GROUP BY qry_BENJobItems.item, dbo_item.description, IIf(([qty_req]-[qty_on_hand])<0,0,([qty_req]-[qty_on_hand])), dbo_item.product_code, Switch(((IIf(([qty_req]-[qty_on_hand])<0,0,([qty_req]-[qty_on_hand])))=0) And ((([qty_on_hand]-[qty_req])/[qty_req])<=0.2),"Please check manually")

HAVING (((dbo_item.product_code) Not Like "RM-CANDY" And (dbo_item.product_code) Not Like "FG - CLRM" And (dbo_item.product_code) Not Like "RM-SubAssy"))

ORDER BY qry_BENJobItems.item;

0 个答案:

没有答案