Google spreadsheet Query Error - column doesn't exist

后端 未结 2 533
野趣味
野趣味 2020-12-08 21:22

Another problem with Google Spreadsheet API. I\'m trying to use QUERY() function in order to get all customers from our database who are from Warsaw. Google API

相关标签:
2条回答
  • 2020-12-08 21:33

    If you are using the Query function with a direct reference to a rectangle of cells, then you use capital letters to refer to the columns. However, if you are using Query against the output of an array formula, such as the return from ImportRange, then you instead need to use Col1, Col2, ... to refer to the columns. So, your example query string would need to read:

    "select Col2 where Col5 contains 'Warszawa'"
    

    Working example:

    =Query(ImportRange("0AtEH2Kw9zfIodEQ2dFNFam9sdEFEZlVnNEV3ZEZMZEE", "data!A:G"), "select Col3, count(Col4) group by Col3 order by count(Col4) desc label count(Col4) 'count'")
    

    I've no idea why it doesn't just let you use names from a header row.

    0 讨论(0)
  • 2020-12-08 21:50

    Alternatively you can try the FILTER function in this case and then you don't need to bother with SQL. :)

    =FILTER(ImportRange("0ArsOaWajjzv9dEdGTUZCWFc1NnFva05uWkxETVF6Q0E"; "Kuchnia polska!B3:B40"); ImportRange("0ArsOaWajjzv9dEdGTUZCWFc1NnFva05uWkxETVF6Q0E"; "Kuchnia polska!e3:e40")="Warszava")

    Although I admit that it's not so pretty because of the two importRange functions.

    Hope it helped anyway.

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