Search code examples
limitgoogle-sheets-query

Use limits with numerical cell reference in Google Sheets Query


I have a query on my Google Sheet in which I use a cell reference in the 'where' condition. The formula is similar to the following example. The referred cell 'F2' contains only numerical data, hence the &F2 after the double quotes. This query statement works fine and the output is as expected.

=query(DataRange,"select A,B,F where D>="&F2)

However, I need just one result (the first occurrence) as output and would like to use the 'limit' function. I can't figure out how or where I should insert 'limit 1' in this query. Any help is appreciated.


Solution

  • =query(DataRange,"select A,B,F where D>="&F2 & " limit 1 offset 0")