PostgreSQL: Advanced Queries

PostgreSQL: Advanced Queries

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 2h 50m | 437 MB

In this course, database expert Adam Wilbert introduces you to a number of advanced query techniques that you can use to better understand your data. Statistical analyses involve understanding the shape and size of the full data set, and deeper insights can be gained by grouping data together to obtain some very useful metrics. Adam shows you how to create basic groups and apply aggregate calculations, then moves into window functions that create subgroups for more granular analysis. He goes over statistics that are based on sorted data within groups, such as the median value, the first and third quartiles of a dataset, the most frequent value, and more. Adam also covers ranking, hypothetical sets, percentile functions, and conditional expressions for further manipulating query result sets. He concludes with some additional querying techniques that you may find useful in solving common problems.

Table of Contents

1 Gain additional insights from your PostgreSQL data
2 What you should know
3 Using the exercise files

1. Obtain Summary Statistics by Grouping Rows
4 Using GROUP BY to aggregate data rows
5 Obtain general-purpose aggregate statistics
6 Evaluate columns with Boolean aggregates
7 Find the standard deviation and variance of a dataset
8 Include overall aggregates with ROLLUP
9 Return all possible combinations of groups with CUBE
10 Segmenting groups with aggregate filters
11 Challenge Group statistics
12 Solution Group statistics

2. Use Window Functions to Perform Calculations across Row Sets
13 Create a window function with an OVER clause
14 Partition rows within a window
15 Streamline partition queries with a WINDOW clause
16 Ordering data within a partition
17 Calculate a moving average with a sliding window
18 Return values at specific locations within a window
19 Challenge Leverage window functions
20 Solution Leverage window functions

3. Statistics Based on Sorted Data within Groups
21 Calculate the median value of a dataset
22 Calculate the first and third quartiles of a dataset
23 Find the most frequent value within a dataset with MODE
24 Determine the range of values within a dataset
25 Challenge Retrieve statistics of a dataset with groups
26 Solution Retrieve statistics of a dataset with groups

4. Ranking Data with Windows and Hypothetical Sets
27 Rank rows with a window function
28 Find a hypothetical rank
29 View top performers with percentile ranks
30 Evaluate probability with cumulative distribution
31 Challenge Evaluate rankings within a dataset
32 Solution Evaluate rankings within a dataset

5. Define Output Values with Conditional Expressions
33 Define values with CASE statements
34 Merge columns with COALESCE
35 Convert values to null with NULLIF

6. Additional Querying Techniques for Common Problems
36 Output row numbers with query results
37 Cast values to a different data type
38 Move rows within a result with LEAD and LAG
39 Use an IN function with a subquery
40 Define WHERE criteria with a series
41 Challenge Calculations across rows
42 Solution Calculations across rows

43 Next steps