SQL query design patterns and best practices a practical guide to writing readable and maintainable SQL queries using its design patterns

Enhance your SQL query writing skills to provide greater business value using advanced techniques such as common table expressions, window functions, and JSON Purchase of the print or Kindle book includes a free PDF eBook Key Features Examine query design and performance using query plans and indexe...

Full description

Bibliographic Details
Main Author: Hughes, Steve, author (author)
Other Authors: Hughes, Steve, author (author)
Format: eBook
Language:Inglés
Published: [Place of publication not identified] : Packt Publishing, Limited [2023]
Edition:1st ed
Subjects:
See on Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009730939906719
Table of Contents:
  • Cover
  • Title Page
  • Copyright and Credits
  • Contributors
  • Table of Contents
  • Preface
  • Part 1: Refining Your Queries to Get the Results You Need
  • Chapter 1 - Reducing Rows and Columns in Your Result Sets
  • Technical requirements
  • Identifying data to remove from the dataset
  • Reducing the amount of data
  • Understanding the value of creating views versus removing data
  • Exploring the impact of row and column reductions on aggregations
  • Summary
  • Chapter 2 - Efficiently Aggregating Data
  • Technical requirements
  • Identifying data to be aggregated
  • Determining when data should be aggregated
  • The AVG() function
  • The SUM() function
  • The COUNT() function
  • The MAX() function
  • The MIN() Function
  • Improving performance when aggregating data
  • Summary
  • Chapter 3 - Formatting Your Results for Easier Consumption
  • Technical requirements
  • Using the FORMAT() function
  • Format() with culture
  • Format() with custom formatting strings
  • Formatting dates and numbers with functions
  • Formatting dates and numbers with CONVERT() and CAST()
  • Formatting numbers with ROUND() and CEILING()
  • Comparing FORMAT(), CONVERT(), and CAST()
  • Alias columns with meaningful names
  • Summary
  • Chapter 4 - Manipulating Data Results Using Conditional SQL
  • Technical requirements
  • Using the CASE statement
  • Using a simple CASE expression in a SELECT statement
  • Using a searched CASE expression in a SELECT statement
  • Using CASE in an ORDER BY statement
  • Using CASE in an UPDATE statement
  • Using CASE in a HAVING statement
  • Using the COALESCE() expression
  • How to use COALESCE()
  • Comparing COALESCE() and CASE()
  • Using ISNULL() function
  • How to use ISNULL()
  • Comparing ISNULL() and COALESCE()
  • Summary
  • Part 2: Solving Complex Business and Data Problems in Your Queries
  • Chapter 5 - Using Common Table Expressions.
  • Technical requirements
  • Creating CTEs
  • Set theory for queries
  • Creating a more complex CTE
  • Creating a recursive CTE
  • Creating the hierarchical data
  • Creating the recursive CTE
  • Recursive alternative
  • Summary
  • Chapter 6 - Analyze Your Data Using Window Functions
  • Technical requirements
  • Understanding window functions
  • Using a window function in a query
  • Adding a partition to the results
  • Window functions with frames
  • Scenarios and business problems
  • Days between orders
  • Finding a pattern
  • Finding first N records of every group
  • Running totals
  • First and last record in the partition
  • Year-over-year growth
  • Chapter 7 - Reshaping Data with Advanced Techniques
  • Technical requirements
  • Working with the PIVOT operator
  • Using PIVOT dynamically
  • Working with the UNPIVOT operator
  • Understanding hierarchical data
  • Summary
  • Chapter 8 - Impact of SQL Server Security on Query Results
  • Technical requirements
  • Why is data missing from my result set?
  • Understanding SQL Server security
  • Validating security settings
  • Summary
  • Part 3: Optimizing Your Queries to Improve Performance
  • Chapter 9 - Understanding Query Plans
  • Technical requirements
  • Understanding query optimization techniques
  • Understanding the Query Optimizer
  • Understanding and exploring the Query Execution Plan
  • Comparing execution plans
  • Analyzing the query plan
  • Summary
  • Chapter 10 - Understanding the Impact of Indexes on Query Design
  • Technical requirements
  • Understanding index and index types
  • Using CREATE to create an index
  • The DROP index
  • Using RENAME to rename an index
  • Modifying indexes
  • The ALTER index
  • Exploring the types of indexes
  • Clustered indexes
  • The NONCLUSTERED index
  • The UNIQUE index
  • The filtered index
  • The covering index
  • The impact of indexes on query design.
  • Understanding index maintenance
  • The REBUILD index
  • The REORGANIZE index
  • Caution
  • Summary
  • Further reading
  • Part 4: Working with Your Data on the Modern Data Platform
  • Chapter 11 - Handling JSON Data in SQL Server
  • Technical requirements
  • Introducing JSON functionality built into SQL Server
  • The basics of JSON
  • JSON functions in SQL Server
  • JSON as data in SQL Server
  • JSON path in SQL Server
  • Formatting results as JSON in SQL Server
  • Using FOR JSON
  • Filling the table
  • Working with JSON data in SQL queries
  • Discovering JSON data in SQL Server
  • Extracting JSON data in SQL Server
  • Modifying JSON data in SQL Server
  • Building tabular results from JSON data in SQL Server
  • Summary
  • Chapter 12 - Integrating File Data and Data Lake Content with SQL
  • Technical requirements
  • Understanding the OPENROWSET (BULK..) function
  • Required security and storage permissions
  • Understanding external tables
  • Summary
  • Chapter 13 - Organizing and Sharing Your Queries with Jupyter Notebooks
  • Technical requirements
  • Creating Jupyter notebooks in Azure Data Studio
  • Understanding notebooks in Azure Data Studio
  • Creating a notebook in Azure Data Studio
  • Creating the Jupyter book
  • Adding a notebook to your Jupyter book
  • Adding queries in your Jupyter notebooks
  • Creating connections in your notebook
  • Creating and executing SQL code in your notebook
  • Formatting results
  • Exporting results
  • Resetting results
  • Documenting your code with markdown in your notebooks
  • Adding a text block to your notebook
  • Creating a header for your notebook
  • Using basic markdown for documentation
  • Adding images and links to your documentation
  • Managing and sharing your queries with Jupyter notebooks
  • Simple sharing of Jupyter books and notebooks
  • Using GitHub to collaborate on your notebook.
  • Integrating third-party Jupyter books
  • Summary
  • Appendix - Preparing Your Environment
  • Prerequisites for running the exercises
  • Choosing a platform
  • Setting up the Azure environment
  • Setting up the SQL Server developer environment
  • Index
  • Other Books You May Enjoy.