LoginSignup
2
1

More than 1 year has passed since last update.

Google スプレッドシートのQUERY関数でBY列の値を取得する

Posted at

問題

QUERY関数でBY列を指定しようとするとエラーになる。

=QUERY('シート1'!A:BZ, "select Y, AY, BY where A = 1", -1)

原因

「BY」はSQLの予約語のため。
GROUP BY句やORDER BY句で使用するため、PARSE_ERROR が起きています。。

エラーメッセージ
関数 QUERY のパラメータ 2 のクエリ文字列を解析できません: PARSE_ERROR: Encountered " "by" "BY "" at line 1, column 15.

解決策

列名を指定する「BY」をバッククォートで括ると値を取得できる。

=QUERY('シート1'!A:BZ, "select Y, AY, `BY` where A = 1", -1)
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1