Main content

Google Sheets QUERY Paid Rows Formula

By Szabó Gergő · Updated

QUERY can select, filter, and sort in one formula. Keep the status column as consistent text.

Syntax and arguments

=QUERY(A1:D200,"select A, C, D where B = 'Paid' order by D desc",1)
data
The table, usually including a header row.
query
The statement in quotes.
headers
1 when row 1 is a header.

QUERY paid rows examples

01
Paid rows only

Status in B, amount in D.

=QUERY(A1:D200,"select A, C, D where B = 'Paid' order by D desc",1)

Returns name, date, and amount for Paid, largest first.

02
Two statuses

Paid or Pending.

=QUERY(A1:D200,"select * where B = 'Paid' or B = 'Pending'",1)

OR is inside the quoted statement.

03
Amount threshold

Minimum in G1.

=QUERY(A1:D200,"select A, D where D >= "&G1&" and B = 'Paid'",1)

Numbers concatenate without quotes. Text still uses single quotes.

Common mistakes

  • Mixed numbers and text in D

    QUERY types a column from the majority. Clean D or use FILTER.

  • Double quotes inside WHERE

    Text literals use single quotes inside the double-quoted statement.

  • Wrong header count

    If the first data row becomes a header, set headers to 0 or 1 explicitly.

QUERY paid rows FAQ

Does Excel have QUERY?

No. Use FILTER or SUMIFS in Excel.

Can I group totals?

=QUERY(A1:D200,"select B, sum(D) where D is not null group by B",1).

How do I keep headers when empty?

QUERY with no matches can drop headers. FILTER plus IFERROR is more predictable for empty results.