0

Currently I use Google Sheets as a database, which has more than 1000 columns from A to AGH. If the query contains column BY or column OR, the result will be null.

How can I avoid that column names cannot be mixed with query commands (by and or) ?

1
  • You can use =QUERY({A:AGH},"select Col1, Col77, Col408") Col177 for BY and Col408 for OR. Commented Sep 29, 2022 at 5:55

1 Answer 1

3

As written in official documentation:

Identifiers (or IDs) are text strings that identify columns.

Important: If your identifier

Has spaces,
Is a reserved word,
Contains anything but alphanumeric characters or underscores ([a-zA-Z0-9_]), or
Starts with a digit

it must be surrounded by back-quotes (not single quotes).

=QUERY(BY1:BY4,"SELECT `BY`",0) 

Alternatively, {} removes the range references and only puts the values, which can be referenced with Col numbers.

=QUERY({BY1:BY4},"SELECT Col1",0) 
Sign up to request clarification or add additional context in comments.

2 Comments

Learn something new.
````` -@TheMaster

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.