简体   繁体   English

你可以在谷歌表格上的查询 function 中使用和/或一起使用吗

[英]Can you use and/or together in a Query function on google sheets

I am trying to use the below function which works when "not" is removed.我正在尝试使用以下 function ,它在删除“不”时有效。

QUERY(Sheet:A,L,"SELECT A,G,H,I,J,K WHERE F='City' AND H='model' AND I>=Number AND (not C contains 'AA1' or not C Contains 'AB1')",1) QUERY(Sheet:A,L,"SELECT A,G,H,I,J,K WHERE F='City' AND H='model' AND I>=Number AND (不是 C 包含 'AA1' 或不包含 C 包含'AB1')",1)

we can test with matches and regex.我们可以使用匹配和正则表达式进行测试。 if it still not working for you then the dataset is insufficient.如果它仍然不适合您,则数据集不足。

=QUERY(Sheet!A:L,
 "SELECT A,G,H,I,J,K 
  WHERE F='City' 
    AND H='model' 
    AND I>=Number 
    AND not C matches 'AA1|AB1'", 1)

Just a postscript to this, if you did want to use Contains it should be只是对此的附言,如果您确实想使用包含它应该是

=QUERY(Sheet1!A:L,"SELECT A,G,H,I,J,K WHERE F='City' AND H='Sedan' AND I>=2016 AND not (C contains 'BMW 3 series' or C Contains 'Audi A4')",1)

Your original formula would only exclude a row that contained both BMW 3 series and Audi A4 because您的原始公式将仅排除包含 BMW 3 系列和 Audi A4 的行,因为

(not C contains 'BMW 3 series' or not C Contains 'Audi A4'",1)

is equivalent to相当于

not (C contains 'BMW 3 series' and C Contains 'Audi A4'",1)

by de Morgan's theorem德摩根定理

So given the following data所以给定以下数据

在此处输入图像描述

Your formula would retrieve您的公式将检索

在此处输入图像描述

while the correct result is而正确的结果是

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM