Formula guide · Google Sheets · Updated May 13, 2026

How to Use QUERY in Google Sheets

Use QUERY to select, filter, group, sort, and label data with a SQL-like formula in Google Sheets.

Quick Answer

QUERY is best when you need one formula to filter, choose columns, sort, group, or relabel a table in Google Sheets.

Copyable Formula

=QUERY(A1:D20,"select A, sum(D) where C = 'Paid' group by A label sum(D) 'Paid total'",1)

Syntax

=QUERY(data, "select A, B where C > 100", headers)

Google Sheets

Worked Example

ACD
RegionStatusAmount
WestPaid120
EastOpen90
WestPaid80

Result: Groups paid amounts by region and labels the total column.

Steps

  • Select the full data range, including headers when useful.
  • Write the query string with select, where, group by, order by, or label.
  • Set the header count at the end so Sheets interprets labels correctly.

Common Mistakes

  • Using spreadsheet column letters from the sheet instead of the selected range position.
  • Forgetting single quotes around text values inside the query string.
  • Mixing numbers and text in the same column, which can confuse QUERY.

Excel vs Google Sheets Notes

This page is focused on Google Sheets. Excel may require a different function, pivot table, or Power Query workflow.

Editorial check: This guide was last updated May 13, 2026. Formula behavior can vary by Excel version, Google Sheets rollout, and spreadsheet locale.

FAQ