4
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

BigQuery で WHEN CASE 文が書けない時の対処法

Last updated at Posted at 2015-10-09

問題

次のクエリは使えない。

SELECT
 CASE fruit
   WHEN 'Apple' THEN 'is apple'
   WHEN 'Orange' THEN 'is orange'
   ELSE 'none'
END AS fruit_kind;
Query Failed
Error: searched case expression not supported at: 

(サポートされていません)

解決

「WHEN 1行ごとに CASEの対象を、重複して書く」方法ならいけた。

SELECT
 CASE
   WHEN fruit = 'Apple' THEN 'is apple'
   WHEN fruit = 'Orange' THEN 'is orange'
   ELSE 'none'

結果:

Row	fruit_kind	 
1	is apple	 

補足

  • 2015年10月9日現在の情報。

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

メンター受付

4
7
1

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
4
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?