# How to rename column headers in a QUERY in Google Sheets

Add a label clause at the end, one name per column: `=QUERY(A1:F13,"select B, sum(E), sum(F) group by B label B 'Sales rep', sum(E) 'Units', sum(F) 'Revenue'",1)`.

**Google Sheets:** `=QUERY(A1:F13,"select B, sum(E), sum(F) group by B label B 'Sales rep', sum(E) 'Units', sum(F) 'Revenue'",1)`

**Excel:** Excel has no QUERY function. Build the result with a formula and stack your own headers on top: `=VSTACK({"Sales rep","Units","Revenue"},…)`.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- |
| Date | Rep | Region | Product | Units | Revenue |
| 2026-07-03 | Ana Ruiz | East | Widget | 40 | 2080 |
| 2026-07-06 | Raj Patel | West | Gadget | 25 | 2225 |
| 2026-07-10 | Lee Chen | East | Gizmo | 12 | 1740 |
| 2026-07-14 | Ana Ruiz | North | Gadget | 30 | 2670 |
| 2026-07-17 | Kim Ortiz | West | Widget | 55 | 2860 |
| 2026-07-21 | Raj Patel | East | Widget Pro | 18 | 1422 |
| 2026-07-24 | Lee Chen | South | Gadget | 22 | 1958 |
| 2026-07-29 | Kim Ortiz | East | Gizmo | 9 | 1305 |
| 2026-08-04 | Mo Diaz | North | Gizmo | 14 | 2030 |
| 2026-08-07 | Raj Patel | South | Widget | 20 | 1040 |
| 2026-08-12 | Kim Ortiz | North | Gadget | 16 | 1424 |
| 2026-08-18 | Mo Diaz | East | Gizmo Mini | 28 | 1092 |

Formula in H1: `=QUERY(A1:F13,"select B, sum(E), sum(F) group by B label B 'Sales rep', sum(E) 'Units', sum(F) 'Revenue'",1)`

Result (spills 6 × 3): Sales rep, Units, Revenue; Ana Ruiz, 70, $4,750; Kim Ortiz, 80, $5,589; Lee Chen, 34, $3,698; Mo Diaz, 42, $3,122; Raj Patel, 63, $4,687

## How it works

Without a label clause, totals get headers like "sum Units" and "sum Revenue". `label` takes pairs of a column or expression and the new header in single quotes. Each expression must be written exactly as in select: `sum(E)`, not `E`.

## Other ways

- `=QUERY(A1:F13,"select B, sum(E), sum(F) group by B",1)`: The default headers, for comparison. (Headers read Rep, sum Units and sum Revenue.)

## Common mistakes

- label goes after order by, limit and offset, and before format. Anywhere else the query fails.
- Labelling a column that isn't selected returns an error. Check that every expression in label also appears in select.
- An empty label, `sum(F) ''`, clears that header but still leaves the header row in place.

## Questions

**How do I rename just one column?**

Label only that one: `label sum(F) 'Revenue'`. The others keep their headers.

**Can label use a cell value?**

Yes, by joining it in: `"… label sum(F) '"&I1&"'"`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/rename-query-column-headers
