在查询函数的第二个参数中如何引用单元格值(字符串)?

huangapple go评论100阅读模式
英文:

(Google Sheets) How can I reference a cell value (string) in the 2nd parameter of the query function?

问题

=QUERY(Sheet1!A:E, "select Col4 where Col3 = " & A2, 0)

英文:

Imagine I have a string value at cell A2 = "name".

I want to use query in such a way that I can reference the value of the cell in the second parameter like this:

=QUERY(Sheet1!A:E, "select Col4 where Col3 = 'A2' ", 0)

But of course, that won't work because since the parameter is inside '', the function reads it as a string (as A2 instead of name).

How can I reference the cell itself so that it will read the value of the cell instead of 'A2'?

答案1

得分: 2

您可以尝试:

=QUERY({Sheet1!A:E}, "select Col4 where Col3 = '"&A2&"' ", 0)

=QUERY(Sheet1!A:E, "select D where C = '"&A2&"' ", 0)

=filter(Sheet1!D:D,Sheet1!C:C=A2)
英文:

<!-- language-all: js -->

You may try:

=QUERY({Sheet1!A:E}, &quot;select Col4 where Col3 = &#39;&quot;&amp;A2&amp;&quot;&#39; &quot;, 0)

OR

=QUERY(Sheet1!A:E, &quot;select D where C = &#39;&quot;&amp;A2&amp;&quot;&#39; &quot;, 0)

OR

=filter(Sheet1!D:D,Sheet1!C:C=A2)

huangapple
  • 本文由 发表于 2023年8月9日 14:20:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76865068-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定