0
0

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 3 years have passed since last update.

私のbigquery備忘録

Last updated at Posted at 2019-12-10

BigQueryを扱うことになったが、ここ数年はsqlserverぐらいしか触って来なかったので、よく使う関数やらを備忘録程度に書き留める

  1. とりあえず使った関数を書き連ねる ←いまここ
  2. カテゴリーとかで分ける

使った・しらべた

現在時刻

  • CURRENT_DATE()

  • 戻りデータの型 DATE
    sqlserverで言うところのgetdate()

  • CURRENT_DATETIME()

    • 戻りデータの型 DATE
  • CURRENT_TIMESTAMP()

    • 戻りデータの型 CURRENT_TIMESTAMP
      使い分けがいるみたい

TIMESTAMP型のUTCからJST変換

FORMAT_TIMESTAMP('%Y-%m-%d %H:%M:%S', created_at, 'Asia/Tokyo')

日付がついたテーブルの指定方法

select *
from `tabel_*`
where _TABLE_SUFFIX = FORMAT_DATE("%Y%m%d",CURRENT_DATE())`

_TABLE_SUFFIXがポイント
``

文字列検索

  • STRPOS(string, substring)
  • 戻りデータの型 int64
    sqlserverで言うところのCHARINDEX

NULL置換

  • IFNULL
    • ISNULLじゃない
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?