Skip to content

Fix QUERY LIMIT / OFFSET mistakes in Google Sheets (not empty WHERE)

Updated

QUERY limit caps how many data rows spill. offset skips rows after the sort/filter, before the cap. limit 0 is a legal way to return nothing. offset larger than the table is also nothing. Both present as #N/A with Query completed with an empty output — the same tooltip as a WHERE miss. limit is not a filter: limit A = 101 does not parse as a condition.

This page is LIMIT / OFFSET. It is not QUERY no rows (where A = 999). It is not QUERY parse string. It is not QUERY PIVOT. Keep the Google Sheets UI in English.

  1. Open a blank spreadsheet. In A1 type sku, B1 name. A2 101. B2 Widget. A3 102. B3 Gadget. A4 103. B4 Lamp. A5 104. B5 Gear. Four products.

LIMIT that works. In D1 type limit2. In D2 enter =QUERY(A1:B5,"select A,B limit 2",1). The spill is the header plus 101 / Widget and 102 / Gadget. That block is the control: limit is a count, not a sku.

OFFSET past the table. In D6 type offset10. In D7 enter =QUERY(A1:B5,"select A,B offset 10",1). Four data rows. Skip 10. The cell shows #N/A. Tooltip: Query completed with an empty output. Leave D7 broken.

D7 selected. Formula bar shows =QUERY(A1:B5,"select A,B offset 10",1). D7 is #N/A. Tooltip: Query completed with an empty output. D2 still spills two products. A2:A5 is 101–104.

LIMIT 0. In F1 type limit0. In F2 enter =QUERY(A1:B5,"select A,B limit 0",1). #N/A, empty output. You asked for zero rows. Leave F2 broken.

LIMIT used like WHERE (parse). In F5 enter =QUERY(A1:B5,"select A,B limit A = 101",1). #VALUE!, Unable to parse query string. limit wants a number, not a condition. Leave F5 as the parse contrast. That family is QUERY parse string.

WHERE miss contrast. In H2 enter =QUERY(A1:B5,"select B where A = 999",1). Also empty #N/A. The clause is where, not offset. That primer is QUERY no rows. Leave H2 as contrast. All four skus are still on the sheet.

OFFSET then LIMIT. In H6 enter =QUERY(A1:B5,"select A,B offset 1 limit 2",1). Skip Widget, take Gadget and Lamp. Working. Order is offset then limit in the statement (both after select).

Leave D7 and F2 as empty-output from paging. Leave F5 as parse. Leave H2 as WHERE. Leave D2 as the working limit 2.

  • offset 10 on four rows skips everything. Empty output #N/A is success for that statement, not a broken QUERY engine.
  • limit 0 is the same empty #N/A. It is not “unlimited.” Unlimited is omitting limit.
  • Headers (1 as the third QUERY argument) do not count as a data row you can offset back. You still get #N/A when no data row remains. You do not get a header-only spill you can treat as a table in every case.
  • limit A = 101 is a parse error. Filtering is where A = 101. Paging is limit N.
  • order by happens before offset/limit. offset 1 without order by skips whichever row is first in the range, not “the smallest sku.”

This is not mixed dates. See QUERY mixed dates.

This is not contains case. See QUERY contains / matches.

This is not FILTER #N/A. See FILTER no match.

Leave D7, F2, F5, and H2 broken.

Page inside the table. Keep D2: limit 2. For the last two skus: =QUERY(A1:B5,"select A,B offset 2",1) (101–102 skipped, 103–104 remain). For “start at row index k” compute offset from COUNTA — do not guess 10 on a four-row demo.

D2 selected. Formula bar shows =QUERY(A1:B5,"select A,B limit 2",1). Spill is sku/name plus 101 Widget and 102 Gadget. D7 is still #N/A from offset 10. F2 is still #N/A from limit 0.

Filter vs page. Sku 101: where A = 101, not limit. Keep F5 broken as the reminder.

When empty paging is allowed, wrap: =IFNA(QUERY(A1:B5,"select A,B offset 10",1),"none"). Only after you know offset is the reason. See IFERROR vs IFNA. Do not IFNA F5 (#VALUE! parse).

If #N/A empty output and where is missing, read limit / offset. If the tooltip is Unable to parse, you put a condition on limit. If where A = 999 is in the string, that is the no-rows primer.

OFFSET past the end vs WHERE miss vs LIMIT 0

Section titled “OFFSET past the end vs WHERE miss vs LIMIT 0”

All three can be empty #N/A.

offset 10 → paging past the data (D7). Shrink offset.

limit 0 → you asked for zero (F2). Omit limit or pass a positive count.

where A = 999 → no sku (H2). See QUERY no rows. The next step is the criterion, not the page size. Parse errors never reach paging.