SQL MIN Tutorial

SQL Tutorial: MIN Function

Learn about the MIN function in SQL, a tool used to retrieve the minimum value of a given column. Discover how this function can be applied in a basketball league scenario, where you could use it to find the player with the least assists.

Key Insights

  • The MIN function in SQL is used to find the minimum value of a given column in a dataset.
  • It operates by retrieving the lowest value from the dataset's chosen column.
  • The syntax for utilizing the MIN function is: SELECT MIN(column_1) FROM table ;
  • Its practical application can be seen in a basketball league database, where it can locate the player with the least assists.
  • In this instance, the SQL query using the MIN function is implemented to retrieve the desired data.
  • The result of executing this function rightfully displays the player with the least assists.

How MIN Works

  • Returns Lowest Value

    MIN retrieves the minimum value of a given column.

  • Syntax

    SELECT MIN(column_1) FROM table;

  • Common Use

    Finding the player with the fewest assists — SELECT MIN(assists) FROM players;

  • NULLs Are Skipped

    MIN ignores NULL values — only considers actual numbers.

MIN Function

  • The MIN function is used to find the minimum value of a given column.

  • It retrieves the minimum value of a given column from our data.

  • Syntax: SELECT MIN(column_1) FROM table ;

Example

Let’s say we have a basketball league and we keep records of each player, which team they are on, and their basic statistics.

Stats Table

If we wanted to use a SQL query to find the player with the least assists, we would write the following:

SQL Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

SQL MIN statement

Once we hit ENTER and run, our result should be as follows:

SQL MIN Result

Learn more in these courses

How to Learn SQL

Master SQL with hands-on training. SQL is one of the most in-demand programming languages and is used across a variety of professions.

Yelp Facebook LinkedIn YouTube Twitter Instagram