MIN and MAX

Some of the most important information is a range of values contained within a dataset. We can hardly offer statistics for the year 2016 in a situation in which our data contains records beginning in 2017. This is why we need to explore dates or numerical ranges. For such purposes, MIN and MAX functions are very useful, but both functions ignore NULLs. In other words, NULL is not the minimum or maximum value in datasets.

Let's take a look at the behavior of both functions. In the AdventureWorks database used in examples throughout this chapter is a table named HumanResources.Employee. In order to better imagine the MIN and MAX behavior, let's make a copy of the table and then we'll adjust a structure and data. To do this, execute ...

Get Hands-On Data Science with SQL Server 2017 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.