Get row number with Google spreadsheet query language

后端 未结 2 1510
悲哀的现实
悲哀的现实 2021-01-05 12:15

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 func

相关标签:
2条回答
  • 2021-01-05 13:05

    Regarding the accepted answer, keep in mind that from Google Documentation some users need to change

    =query({A2:B, arrayformula(row(A2:B))}, "select Col1, Col3 where Col2 = 1")
    

    to

    =query({A2:B\ arrayformula(row(A2:B))}, "select Col1, Col3 where Col2 = 1")
    

    since the array sintax can change (Google Documentation):

    Note: For countries that use commas as decimal separators (for example €1,00), commas would be replaced by backslashes () when creating arrays.

    0 讨论(0)
  • 2021-01-05 13:07

    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.

    0 讨论(0)
提交回复
热议问题