# How to combine two ranges in one QUERY in Google Sheets

Stack the ranges in curly braces with a semicolon and refer to columns as Col1, Col2: `=QUERY({A1:C6;E2:G6},"select Col1, Col3 order by Col3 desc",1)`.

**Google Sheets:** `=QUERY({A1:C6;E2:G6},"select Col1, Col3 order by Col3 desc",1)`

**Excel:** Excel has no QUERY function. Stack the tables with VSTACK and sort: `=SORT(CHOOSECOLS(VSTACK(A2:C6,E2:G6),1,3),2,-1)`.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F | G |
| --- | --- | --- | --- | --- | --- | --- |
| Rep | Deals | Revenue |  | Rep | Deals | Revenue |
| Ana Ruiz | 12 | 48200 |  | Raj Patel | 9 | 51750 |
| Lee Chen | 15 | 39900 |  | Mo Diaz | 11 | 45100 |
| Ivy Shah | 13 | 52900 |  | Eve Lund | 14 | 57800 |
| Tom Reyes | 8 | 31200 |  | Noor Ali | 7 | 30500 |
| Sam Cole | 10 | 44600 |  | Ben Ford | 12 | 47300 |

Formula in I1: `=QUERY({A1:C6;E2:G6},"select Col1, Col3 order by Col3 desc",1)`

Result (spills 11 × 2): Rep, Revenue; Eve Lund, $57,800; Ivy Shah, $52,900; Raj Patel, $51,750; Ana Ruiz, $48,200; Ben Ford, $47,300; Mo Diaz, $45,100; Sam Cole, $44,600; Lee Chen, $39,900; Tom Reyes, $31,200; Noor Ali, $30,500

## How it works

`{A1:C6;E2:G6}` builds one array: the semicolon puts the second range under the first (a comma would put it beside). The first range includes the header row, so the headers argument is 1. Because the data is now an array rather than a sheet range, the columns are called Col1, Col2 and Col3 instead of letters.

## Other ways

- `=QUERY(VSTACK(A1:C6,E2:G6),"select Col1, Col3 order by Col3 desc",1)`: VSTACK does the same stacking and reads more clearly.
- `=QUERY({A2:C6;E2:G6},"select Col1, Col3 where Col3 > 45000 order by Col3 desc",0)`: Without the header row, set headers to 0. Here with a where clause added. (No header, and only revenue over 45,000.)

## Common mistakes

- Column letters don't work on an array: `select A, C` returns an error. Use Col1, Col3.
- Both ranges need the same number of columns, or the array fails with an error about mismatched sizes.
- In some locales the separator for side-by-side columns is a backslash, `{A1:A6\C1:C6}`. The semicolon for stacking is the same everywhere.

## Questions

**How do I query ranges from two sheets?**

Use sheet references inside the braces: `={'East'!A2:C;'West'!A2:C}`, and add `where Col1 is not null` to drop empty rows.

**Can I query data from another file?**

Yes, with IMPORTRANGE inside QUERY. Columns are again Col1, Col2.

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/query-two-ranges-at-once
