gpt4 book ai didi

sql - 谷歌电子表格查询功能列ID不是列的字母

转载 作者:行者123 更新时间:2023-12-05 00:50:21 24 4
gpt4 key购买 nike

好吧...不确定这些是否可以完成。

我在谷歌电子表格中,单元格 A1 = time.. 范围是 A1:C4。

我有一个简单的表格如下:

time   sit   stand 
1 bob mike
2 fred pat
3 chris mike

这是我的查询:

=query($A$1:$C$4,"select A,B,C where C='mike'",0) 

... 非常直截了当。但是,我希望列引用是动态的。所以我需要能够使用标题进行查询。我该怎么做?我已经尝试过以下方法:

=query($A$1:$C$4,"select 'sit ', 'stand' where 'stand' = 'mike' ",0)

=query($A$1:$C$4,"select sit, stand where stand = 'mike' ",0)

并根据此页面的建议: Google spreadsheet Query Error - column doesn't exist

我还尝试了以下方法:

=query($A$1:$C$4,"select Col2, Col3  where Col3 = 'mike' ",0)

=query($A$1:$C$4,"select Col2, Col3 where (Col3) = 'mike' ",0)

=query($A$1:$C$4,"select (Col2), (Col3) where (Col3) = 'mike' ",0)

=query($A$1:$C$4,"select 'Col2', 'Col3' where 'Col3' = 'mike' ",0)

它们都不起作用...有人知道该怎么做或知道是否可行吗?

https://developers.google.com/chart/interactive/docs/querylanguage

这里的例子看起来你可以做到,但这仅适用于应用程序脚本吗?而不是在电子表格函数中?

最佳答案

遗憾的是,在 QUERY 电子表格函数选择子句中,没有通过标题引用列的本地方式。

如果 QUERY 的第一个参数不是显式引用的范围,则可以使用 Colx 表示法。实现此目的的一种方法是将范围括在括号中,并调用 ArrayFormula:

=ArrayFormula(QUERY(($A$1:$C$4),"select Col2, Col3 where Col3 = 'mike'",0))

而且它相当难看,但你可以使用 MATCH 函数来插入标题引用:

=ArrayFormula(QUERY(($A$1:$C$4),"select Col"&MATCH("坐";$A$1:$C$1;0)&", Col"&MATCH("stand ";$A$1:$C$1;0)&"where Col"&MATCH("stand";$A$1:$C$1;0)&"= 'mike'",1))

关于sql - 谷歌电子表格查询功能列ID不是列的字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14767160/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com