Google-sheets – How add column BY to a query?

google sheetsgoogle-sheets-query

How do I include the column BY in a query?
I first tried =unique(query(data_table,"SELECT D, BY"))

Then, I tried to surround it with single quotes =unique(query(data_table,"SELECT D, 'BY'"))

Best Answer

Short answer

Put BY column identifier between back quotes, =unique(query(data_table,"SELECT D, `BY`"))


BY is a Google Query Language keyword. From


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).