SQL Tutorial
Basic SQL
Intermediate SQL
Putting it together
SQL Aggregate Functions
SQL COUNT
SQL SUM
SQL MIN/MAX
SQL AVG
SQL GROUP BY
SQL HAVING
SQL CASE
SQL DISTINCT
SQL Joins
SQL INNER JOIN
SQL Outer Joins
SQL LEFT JOIN
SQL RIGHT JOIN
SQL Joins Using WHERE or ON
SQL FULL OUTER JOIN
SQL UNION
SQL Joins with Comparison Operators
SQL Joins on Multiple Keys
SQL Self Joins
Advanced SQL
SQL Analytics Training
Python Tutorial
Learn Python for business analysis using real-world data. No coding experience necessary.
Start Now
Mode Studio
The Collaborative Data Science Platform
SQL MIN/MAX
Starting here? This lesson is part of a full-length tutorial in using SQL for Data Analysis. Check out the beginning.
In this lesson we'll cover:
The SQL MIN and MAX functions
MIN
and MAX
are SQL aggregation functions that return the lowest and highest values in a particular column.
They're similar to COUNT
in that they can be used on non-numerical columns. Depending on the column type, MIN
will return the lowest number, earliest date, or non-numerical value as close alphabetically to "A" as possible. As you might suspect, MAX
does the opposite—it returns the highest number, the latest date, or the non-numerical value closest alphabetically to "Z."
For example, the following query selects the MIN
and the MAX
from the numerical volume
column in the Apple stock prices dataset.
SELECT MIN(volume) AS min_volume,
MAX(volume) AS max_volume
FROM tutorial.aapl_historical_stock_price
Sharpen your SQL skills
Practice Problem
What was Apple's lowest stock price (at the time of this data collection)?
Try it out See the answerPractice Problem
What was the highest single-day increase in Apple's share value?
Try it out See the answerNext Lesson
SQL AVG