英文:
(Google Sheets) How can I reference a cell value (string) in the 2nd parameter of the query function?
问题
假设我在单元格A2中有一个字符串值为"name"。
我想要使用QUERY函数以这样的方式引用第二个参数中单元格的值:
=QUERY(Sheet1!A:E, "select Col4 where Col3 = 'A2' ", 0)
但是,显然这样是行不通的,因为由于参数位于''之内,函数会将其作为字符串读取(而不是作为name)。
我该如何引用单元格本身,以便它读取单元格的值而不是'A2'?
英文:
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
<!-- language-all: js -->
你可以尝试以下代码:
=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}, "select Col4 where Col3 = '"&A2&"' ", 0)
OR
=QUERY(Sheet1!A:E, "select D where C = '"&A2&"' ", 0)
OR
=filter(Sheet1!D:D,Sheet1!C:C=A2)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论