【SQL】(読了)集中演習 SQL入門 Google BigQueryではじめるビジネスデータ分析((Finished)Introduction to Analysis/SQL Drill)

無事にひととおり終えました。基礎から学べました。

【書籍情報】「集中演習 SQL入門 Google BigQueryではじめるビジネスデータ分析」著者:木田 和廣/発行:インプレス/発売日:2021/2/19

GoogleがBiqQueryという名で提供しているサービス内で、SQLを実行できます。BiqQueryはデータアナリスト認定時に登録していたので、すんなり始められました。というか、だからGoogleにしました。MySQLとか大手もあるんですけど、やっぱりPC実装がなんとも…。あと方言を覚える気になれなかった。Googleは従量課金制だけど、いまの作業なら無料枠内で続けられる想定。(自論:クレカ決済は借金と同じ。((((;゚Д゚))))ガクガクブルブル)


本の特徴

  • データベース構築系一切なし(CREATE,INSERT,UPDATE)。付属サンプルデータをアレコレします。
  • Google BigQueryに特化しており、アカウントの作り方から記載あり。スクショもGoogleのそれです。方言の記載もありません。
  • 初心者に優しい、丁寧な解説。アナリスト認定でSQL基礎を受講したけれど、文法から別の先生に習えた感ある。
  • ちょっと込み入ったことはコラムで補足してあります。(GA4用のUNNESTも少しだけ)


感想

まずは、この本を作ってくれた作者に感謝です。初心者に優しい本でした。おかげさまで手を動かせました。お礼を前提に、感想を書きます。

  1. 巻末200問のドリル半分以上は超基礎、数行で終わる
  2. 各章末問題は巻末問題の終盤あたりの難易度
  3. 解説に出てきていないコマンドが答にくる(巻末ドリル)
  4. 終盤は単語分かってる前提の問題が出てくる
  5. ネットの答に解説なし


1.ドリルって基礎からですよね。うん。でも答えが数行で終わる100問は少しもったいないかも…。(SELECT、FROM含めて数行)ただサンプルが秀逸です。結合まで考えた実践的なデータでした。


2.各章末に確認ドリルがあるんですが、これをクリアできてれば巻末問題前半は楽しいばっかりです。各章末はそれぞれの関数(グループ化やサブクエリや)しか使わないけど、それなり長めの記述になる。


3.は例えば、正規表現やDATEです。四半期を"%Q"、FORMAT_DATEで”%Y-%M”と書ける、なんて章には書いてなくて、CASE+BETWEENで無理くりした自分が笑える。正規表現はもう記載なくて仕方なし、書き方が山のようにあるんだろうなあ。


4.私にとっては最後まで「セッション」「直帰率」の扱いが難儀でした。これらを踏まえた問題に説明がないと改めて調べる羽目に…(「セッション」の定義は一意な「cid」+「session_count」でした)。結果サブクエリが増える…。


5.巻末ドリルの解答はネットに載せてあります。プログラムのあるあるですけど、解法が違うのは多めに見ましょう。答えの数字があってるかを重視!それでも自分はよく間違ってたw 本にも書いてありますが、先生の記述が最善であるとは限りません。好みもありますし。

とはいえ解法コピペしても数字が違ったときは出版社に問い合わせて、丁寧な解説をいただきました。(問224:RFM分析、ページの解答も補足された)


オウンドメディア管理していた側からすると、ユーザーの指摘は有難いものです。ちょっと大きいサイトになると、自分たちのコンテンツが把握できていない状況が生まれます。新しい記事が追加されるばっかりで、過去の精査まで手が回らないのです。なので、「お問い合わせ」したいときはどんどん送った方がいい。返事くれるかはまた別の話ですw

なんでこんなこと言うかって、発行が2021年2月なのに2023年9月の質問でページ修正してもらったので。だいぶ売れている本で、きっと多くの人がこのページを見て答え合わせしたであろうに、誰も指摘しなかったんだろうか。前述のRFM分析については、問い合わせ後数日で解説をしてもらえました。たまたまかな。


*******


Successfully finished reading. I learned from the basics.

[Book information] “Intensive Exercises Introduction to SQL Business Data Analysis with Google BigQuery” Author: Kazuhiro Kida/Publisher: Impress

BiqQuery is a service provided by Google that allows you to execute SQL. I had registered to use BiqQuery when I was certified as a data analyst, so it was easy to get started. In fact, that's reason I used it. There are major companies like MySQL, but I don't have the time to research PC applications. I also didn't want to learn the dialect. Google has a pay-as-you-go system, but the current work is expected to continue within the free tier. (Personal theory: Credit card payments are the same as debt.(((;゚Д゚))))Oh...)


Features of the book

  • No database construction system (CREATE, INSERT, UPDATE) required. Check out the sample data included.
  • Specialises in Google BigQuery and includes information on how to create an account. The screenshots are also from Google. No mention of dialect.
  • Detailed explanations that are beginner friendly.
  • Some more information added in the column. (Also some UNNEST for GA4)


Thoughts

First of all, I would like to thank the author for creating this book. This was a beginner friendly book. Thanks to you, I was able to move my hands.

  1. More than half of the 200 practice questions at the end of the book are basic. The answer is only a few lines.
  2. The problems at the end of each chapter have a difficulty level around the end of the book.
  3. Commands not mentioned in the explanation are included in the answer (exercises at the end of the book).
  4. There are questions that require you to know the words.
  5. No explanation in the answer on the Internet


1. Exercises start with the basics, right? But 100 questions with answers that only take a few lines might be a bit too easy... However, the sample datas are excellent. It was practical data that even considered connections.


2. There is a confirmation exercise at the end of each chapter, but if you can do it, the first half of the questions at the end of the book will be easy. At the end of each chapter, only the functions explained in that chapter (grouping, subqueries, etc.) are used, but the answer is long.


3. For example, regular expressions and DATE. The book does not say that quarter can be written as "%Q" and FORMAT_DATE can be written as "%Y-%M". I could laugh at myself for trying to solve by CASE+BETWEEN.


4. It was difficult for me to deal with "sessions" and "bounce rate" until the end. If there is no explanation for the problem based on these, I will have to look into it again... (The definition of "session" was a unique "cid" + "session_count").


5. The answers to the drills at the end of the book are published online. As is often the case in programming, allow for different solutions. Focus on whether the answers are correct! Even so, I was often wrong. It's also written in the book, but the teacher's description is not always the best.

However, even after copying and pasting the solution, if the numbers were wrong, I contacted the publisher and received a detailed explanation. (Question 224: RFM analysis, the answer on the page had also been added)