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.
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: