Pick columns with select
Step 1 of 3
QUERY asks a range a question, written as text in a language much like SQL: =QUERY(data, "select …"). The answer is a new table.
Click Continue when you're ready.
Already know it? Type the formula straight into E1.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Region | Rep | Amount | |||
| 2 | North | Ann | 120 | |||
| 3 | South | Bo | 80 | |||
| 4 | North | Cy | 200 | |||
| 5 | West | Di | 50 | |||
| 6 | South | Ed | 150 | |||
| 7 | ||||||
| 8 |
Need help?
Why this works
QUERY reads A1:C6 and runs the query on it. "select B, C" keeps columns B and C, in that order, and the header row comes along on top. The result spills down and to the right from E1.
Common mistake: Writing the header names, like select Rep, Amount. QUERY names columns by their letters.
The answer
- E1
=QUERY(1A1:C6,2"select B, C")
In plain words: From 1the table in A1:C6, 2show the Rep and Amount columns.
It runs a query in the Google Visualization query language on a range: pick columns with select, filter with where, total with group by and sort with order by. =QUERY(A1:C6,"select B, C") returns columns B and C with their headers.
+10 points