Here we look at the SQL Functions MAX and MIN. It shows how and when to use them and how to use them both together when combined with GROUP BY.
Content:
00:00 Intro
00:50 What is a SQL function
02:00 The MAX Function
02:40 The MIN Function
03:00 Using them together
Overview of the Max and Min function
The SQL MAX and MIN Functions are known as aggregate functions. These are used to perform a calculation on a set of values. As with all functions, they return a SINGLE value. Thats their job - you ask as question, they provide you with the answer!
What is a Function?
A function is a set of code that has a specific task. They are not able to perform DML statements or change any data, they just perform a calculation and return that value.
In this case you would be asking - what is the maximum value in this result set (MAX) or what is the lowest value in this result set?
Resources
SQL MIN() and MAX() Functions: https://www.w3schools.com/sql/sql_min...
The T-SQL Max Function: https://learn.microsoft.com/en-us/sql...
The T-SQL Min Function: https://learn.microsoft.com/en-us/sql...
SQL Aggregate Functions: https://learn.microsoft.com/en-us/sql...