Skip to Content
初めてのSQL 第3版
book

初めてのSQL 第3版

by Alan Beaulieu, 株式会社クイープ
July 2021
Intermediate to advanced
376 pages
6h 34m
Japanese
O'Reilly Japan, Inc.
Content preview from 初めてのSQL 第3版

16章解析関数

データの量は驚異的なペースで増えており、組織はデータの意味を理解することは言うまでもなく、データをすべて格納することにすら手を焼いています。データ解析は従来、Excel、R、Pythonなどの専用のツールや言語を使ってデータベースサーバーの外で行われてきましたが、SQL言語には解析処理に役立つ関数がしっかり含まれています。従業員を営業成績に基づいてランク付けする必要がある場合や、顧客向けの会計報告書を作成していて3か月間の移動平均を計算する必要がある場合は、SQLの組み込みの解析関数を使ってそうした計算を行うことができます。

16.1 解析関数

データベースサーバーがクエリの評価に必要な手順(結合、フィルタリング、グループ化、並べ替えなど)をすべて完了すると、結果セットが完成して呼び出し元に返す準備が整います。この時点でクエリの実行をいったん止めて、メモリに格納されている状態の結果セットを調べることができるとしたら、どのような解析を行いたいでしょうか。結果セットに売上データが含まれている場合は、営業担当者や地域別に順位を計算するか、期間ごとの差の割合を計算したいかもしれません。結果セットに会計報告用のデータが含まれている場合は、おそらく項目ごとの小計と最終的な総計を計算したいと考えるでしょう。解析関数を利用すれば、これらの解析はもちろん、他の解析も行うことができます。最もよく使われている解析関数には、共通するメカニズムがあります。詳しい説明に入る前に、このメカニズムを見ておきましょう。

16.1.1 データウィンドウ

特定期間の月間売上高を生成するクエリを記述したとしましょう。たとえば次のクエリは、2005年5月から8月の期間のレンタルについて月ごとの支払い総額を計算します。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス

Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス

Titus Winters, Tom Manshreck, Hyrum Wright, 竹辺 靖昭, 久富木 隆一

Publisher Resources

ISBN: 9784873119588Other