访问条件不等于零

时间:2017-07-24 16:25:15

标签: sql ms-access ms-access-2007

我无法使用下面的查询过滤掉零字段。许多记录在" 3年平均值"或" Comp Usage"字段仍包含在结果中。

Query

删除"<> 0"或者"不是空的"条件在输出表中不更改任何内容。 Access正在生成以下SQL:

SELECT 
[active plant parts made from dept produced components usage].assembly_item_no, 
[active plant parts made from dept produced components usage].component_item_no, 
[active plant parts made from dept produced components usage].component_qty, 
[active plant parts made from dept produced components usage].[3 yr average], 
[active plant parts made from dept produced components usage].[comp usage], 
noetix_sys_invus_category_all.[a$cat$item_type] 
INTO   [department component usage and assembly type] 
FROM   [active plant parts made from dept produced components usage] 
       INNER JOIN noetix_sys_invus_category_all 
               ON 
[active plant parts made from dept produced components usage].assembly_item_no = 
noetix_sys_invus_category_all.[a$item$item_number] 
WHERE  ( ( ( 
[active plant parts made from dept produced components usage].[3 yr average] 

) 
<> 0 ) 
  AND ( ( 
  [active plant parts made from dept produced components usage].[comp usage] ) 
<> 0 ) 
  AND ( ( noetix_sys_invus_category_all. [a$cat$item_type] ) = "aft" ) ) 
 OR ( ( ( 
[active plant parts made from dept produced components usage].[3 yr average] 
) 
IS NOT NULL ) 
  AND ( ( 
  [active plant parts made from dept produced components usage].[comp usage] 
        ) 
    IS NOT NULL ) 
  AND ( ( noetix_sys_invus_category_all.[a$cat$item_type] ) = "aft+" ) ) 
OR (( ( noetix_sys_invus_category_all.[a$cat$item_type] ) = "oem" )) 
OR (( ( noetix_sys_invus_category_all.[a$cat$item_type] ) = "oem+" )) 
ORDER  BY 
[active plant parts made from dept produced components usage].[3 yr average] DESC, 
[active plant parts made from dept produced components usage].[comp usage] DESC, 
noetix_sys_invus_category_all.[a$cat$item_type]; 

感谢您的帮助。

2 个答案:

答案 0 :(得分:2)

也许使用HttpURLConnectionin进行简化。我说也许是因为我不完全确定你想要的结果是什么。

nz

或者发言评估通常都很昂贵;因此,如果我们可以使用IN一次进行多次评估,我们就会获得性能优势。

使用WHERE nz([Active Plant Parts Made From Dept Produced Components Usage].[3 Yr Average],0)<>0 AND nz([Active Plant Parts Made From Dept Produced Components Usage].[Comp Usage],0)<>0 AND NOETIX_SYS_INVUS_CATEGORY_ALL.[A$CAT$ITEM_TYPE] in("AFT","AFT+","OEM","OEM+") 我们将空值转换为0,然后将其从结果中排除。因此,在3年平均值或补偿使用率为零或零的情况下,则排除记录。

答案 1 :(得分:1)

在条件行中读取是一个AND语句,因此,例如,Is Not Null仅适用于&#34; AFT +&#34;。

使用单行和And(或Or)关键字。示例(键入单个单元格):

<>0 And Is Not Null

"X" Or "Y" Or "Z"

或重复每个&#34; X&#34;,&#34; Y&#34;等行的第一个表达式。