【发布时间】:2013-01-23 21:35:24
【问题描述】:
好吧...不确定这些是否可以完成。
我在谷歌电子表格中,单元格 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
这里的例子看起来你可以做到,但这仅适用于应用程序脚本吗?而不是在电子表格函数中?
【问题讨论】:
-
看起来答案是否定的。关于能够使用
nameOfColumn而不能使用它的引用似乎存在冲突。所以这通常意味着你不能。
标签: sql google-apps-script google-sheets