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.
Learn the basics of the MIN function and how and when to use it in this tutorial.
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.
If we wanted to use a SQL query to find the player with the least assists, we would write the following:
Once we hit ENTER and run, our result should be as follows: