1

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'"))

2

Short answer

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

Explanation

BY is a Google Query Language keyword. From https://developers.google.com/chart/interactive/docs/querylanguage#Identifiers

Identifiers

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.