使用Google电子表格查询语言获取行号 [英] Get row number with Google spreadsheet query language
问题描述
我想用查询语言获取我需要的数据的行号,ig:select A,ROW_NUMBER()where(B = 1)。
但似乎查询语言没有提供如下的函数:ROW_NUMBER()?
除了查询整列并在JavaScript中进行计数之外,我该怎么做? ?
您可以使用 arrayformula(row(...))
到查询范围,并将其包含在结果中。例子:
$ $ p $ = query({A2:B,arrayformula(row(A2:B))},select Col1,Col3其中Col2 = 1)
这里Col1 = A,Col2 = B,Col3 =行号。由于要查询的数组是在公式内构建的,因此它的列被称为Col1,Col2等。
I'd like to get the row number of the data I need with query language, i.g: select A,ROW_NUMBER() where (B=1).
But it seems the query language doesn't provide function like: ROW_NUMBER()?
How do I do that, other than query the whole column and count it in JavaScript?
You can add a column with arrayformula(row(...))
to the queried range, and include it in results. Example:
=query({A2:B, arrayformula(row(A2:B))}, "select Col1, Col3 where Col2 = 1")
Here Col1 = A, Col2 = B, Col3 = added column with the row number. Since the array to be queried is constructed within the formula, its columns are referred to as Col1, Col2, and so on.
这篇关于使用Google电子表格查询语言获取行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!