Skip to main content

2023 | Buch

SQL Server Analytical Toolkit

Using Windowing, Analytical, Ranking, and Aggregate Functions for Data and Statistical Analysis

insite
SUCHEN

Über dieses Buch

Learn window function foundational concepts through a cookbook-style approach, beginning with an introduction to the OVER() clause, its various configurations in terms of how partitions and window frames are created, and how data is sorted in the partition so that the window function can operate on the partition data sets. You will build a toolkit based not only on the window functions but also on the performance tuning tools, use of Microsoft Excel to graph results, and future tools you can learn such as PowerBI, SSIS, and SSAS to enhance your data architecture skills.

This book goes beyond just showing how each function works. It presents four unique use-case scenarios (sales, financial, engineering, and inventory control) related to statistical analysis, data analysis, and BI. Each section is covered in three chapters, one chapter for each of the window aggregate, ranking, and analytical function categories.

Each chapter includes several TSQL code examples and is re-enforced with graphic output plus Microsoft Excel graphs created from the query output. SQL Server estimated query plans are generated and described so you can see how SQL Server processes the query. These together with IO, TIME, and PROFILE statistics are used to performance tune the query. You will know how to use indexes and when not to use indexes.

You will learn how to use techniques such as creating report tables, memory enhanced tables, and creating clustered indexes to enhance performance. And you will wrap up your learning with suggested steps related to business intelligence and its relevance to other Microsoft Tools such as Power BI and Analysis Services.

All code examples, including code to create and load each of the databases, are available online.

What You Will Learn

Use SQL Server window functions in the context of statistical and data analysisRe-purpose code so it can be modified for your unique applicationsStudy use-case scenarios that span four critical industriesGet started with statistical data analysis and data mining using TSQL queries to dive deep into dataStudy discussions on statistics, how to use SSMS, SSAS, performance tuning, and TSQL queries using the OVER() clause.Follow prescriptive guidance on good coding standards to improve code legibility

Who This Book Is For

Intermediate to advanced SQL Server developers and data architects. Technical and savvy business analysts who need to apply sophisticated data analysis for their business users and clients will also benefit. This book offers critical tools and analysis techniques they can apply to their daily job in the disciplines of data mining, data engineering, and business intelligence.

Inhaltsverzeichnis

Frontmatter
Chapter 1. Partitions, Frames, and the OVER( ) Clause
Abstract
The goal of this chapter is to describe the OVER() clause, its various configurations in terms of how partitions and window frames are created, and how data is sorted in the partition so that the window function can operate on the values. (The OVER() clause together with partitions and window frames is what gives power to the window functions.)
Angelo Bobak
Chapter 2. Sales DW Use Case: Aggregate Functions
Abstract
Our main goal in this chapter is to learn and apply the category of window functions called aggregate functions. We start off by describing the sales data warehouse (DW) called APSales that we will use.
Angelo Bobak
Chapter 3. Sales Use Case: Analytical Functions
Abstract
Now that we have created and familiarized ourselves with the sales data warehouse and created queries that use aggregate window functions, we can move to our next step, learning and creating queries using the analytical functions available with SQL Server.
Angelo Bobak
Chapter 4. Sales Use Case: Ranking/Window Functions
Abstract
This is our last chapter dealing with the sales data warehouse. We will look at the third category of functions called window or ranking functions. We will take the same approach as prior chapters, that is, provide a brief explanation of the function, present the code and the query results, and do some performance analysis and tuning by adding indexes and report tables. Lastly, we will present a data analysis problem called gaps and islands where we use some of the window system functions we studied in Chapter 3 to identify gaps and sequences in dates for sales data.
Angelo Bobak
Chapter 5. Finance Use Case: Aggregate Functions
Abstract
We now turn our focus to the financial industry. As was the case with the past three chapters, we will use the three categories of SQL Server functions available to us to analyze a stock trading scenario. We will dedicate one chapter to each category of functions. Each function will be used in a query. We will examine the results by looking at the output and, then in most cases, copying the output to a Microsoft Excel spreadsheet so we can generate a graph or two to visualize the results.
Angelo Bobak
Chapter 6. Finance Use Case: Ranking Functions
Abstract
Ranking functions, when applied to financial data, can produce interesting and valuable information for analysts or portfolio managers. This information is used to predict future trading patterns based on historical patterns. A properly managed portfolio based on solid analytical data and analysis will generate profits (hopefully).
Angelo Bobak
Chapter 7. Finance Use Case: Analytical Functions
Abstract
This is the last chapter dealing with our financial database. We will put the analytical functions through their paces and perform the usual performance analysis, but we will also take a look at a few strategies that involve variations of the queries, like from CTE- to reporting table–based queries to using memory-enhanced tables to see which scheme yields better performance.
Angelo Bobak
Chapter 8. Plant Use Case: Aggregate Functions
Abstract
This is the first of three chapters that will use a power plant business use case scenario. A picture will give us an idea of the equipment we need to monitor with our window aggregate functions. Please refer to Figure 8-1.
Angelo Bobak
Chapter 9. Plant Use Case: Ranking Functions
Abstract
In this chapter, we use the ranking window functions to perform some analysis on the power plant database. There are only four functions, but we will check out performance as usual and also create a few Microsoft Excel pivot tables and graphs to take our analysis a step further.
Angelo Bobak
Chapter 10. Plant Use Case: Analytical Functions
Abstract
We are going to add a couple of new tools to our toolkit in this chapter. We will take a quick look at Report Builder and also Analysis Services’ multidimensional cubes.
Angelo Bobak
Chapter 11. Inventory Use Case: Aggregate Functions
Abstract
This will be an interesting chapter. Not only will we be taking the window aggregate functions through their paces in an inventory management scenario but we will also learn how to use Microsoft’s premier ETL tool called SSIS to create a process that loads an inventory data warehouse from the inventory database that is used in the queries we will create.
Angelo Bobak
Chapter 12. Inventory Use Case: Ranking Functions
Abstract
Welcome to the third to last chapter of the book. I hope you are enjoying the journey. This time we launch the four ranking window functions against our inventory database and the inventory data warehouse. We will perform the usual analysis of the results and do some performance analysis, but we will also go through the steps to create a web report with Microsoft Report Builder and publish it to a website implemented with SSRS (SQL Server Reporting Services), Microsoft’s premiere reporting architecture.
Angelo Bobak
Chapter 13. Inventory Use Case: Analytical Functions
Abstract
Congratulations! You made it to the last chapter dealing with window functions. We do have one more chapter, Chapter 14, which is a summary chapter that includes a review of the tools we used and also where to obtain them.
Angelo Bobak
Chapter 14. Summary, Conclusions, and Next Steps
Abstract
Congratulations! This is our last chapter. Let’s wrap things up by summarizing what we learned and also looking at the tools in our toolkit and where to get them. I might even tell you how to create the databases and load them too! We will also discuss how to set up the folders for storing code and also the physical database files.
Angelo Bobak
Backmatter
Metadaten
Titel
SQL Server Analytical Toolkit
verfasst von
Angelo Bobak
Copyright-Jahr
2023
Verlag
Apress
Electronic ISBN
978-1-4842-8667-8
Print ISBN
978-1-4842-8666-1
DOI
https://doi.org/10.1007/978-1-4842-8667-8

Premium Partner