【问题标题】:Google docs query when contains value in a range谷歌文档查询何时包含范围内的值
【发布时间】:2018-02-06 10:18:03
【问题描述】:

在谷歌表格中,当 C 列中的单元格包含不同表格上某个范围内的任何值时,我想返回一行。

下面的查询不起作用。我错过了什么?

=QUERY(
'Form Responses 1'!$1:$1000,
" select A:G where C contains 'Sheet2'!$A1:$A26"
)

【问题讨论】:

    标签: google-query-language google-sheets-query


    【解决方案1】:

    如果您尝试匹配不同工作表上某个范围内的字符串值:

    =query('Form Responses 1'!$1:$1000, "SELECT A,B,C,D,E,F,G WHERE A MATCHES '"&JOIN("|",'Sheet2'!$A1:$A26)&"'",1)
    

    希望下图中的语法突出显示使上面的字符串连接运算符更加清晰: GoogleSheets: Select partial row if target column in data set contains value within range declared in another sheet

    【讨论】:

      【解决方案2】:

      我建议在Form Responses 1 中标记感兴趣的行,例如在 H1 中:

      =ArrayFormula(countif(Sheet2!A:A,C1:C))
      

      然后根据标志进行选择,例如:

      =QUERY('Form Responses 1'!$1:$1000,"select * where H=1")
      

      或者如果您不希望出现标志:

      =QUERY('Form Responses 1'!$1:$1000,"select A,B,C,D,E,F,G where H=1") 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-22
        相关资源
        最近更新 更多