MIN Function
The MIN function is a powerful SQL aggregate function that identifies and returns the smallest value within a specified column, making it essential for data analysis and reporting tasks.
This function scans all rows in the target column and efficiently retrieves the minimum value, handling both numeric and date data types seamlessly.
Syntax: SELECT MIN(column_1) FROM table ;
MIN Function Implementation Steps
Identify Target Column
Determine which numeric or date column contains the values you want to find the minimum for in your dataset.
Write SELECT Statement
Use the SELECT keyword followed by MIN function with your chosen column as the parameter.
Specify Source Table
Add the FROM clause to indicate which table contains the data you want to analyze.
Execute and Review
Run the query and verify the returned minimum value matches your expectations for the dataset.
The MIN function works with numeric, date, and even text columns. For text columns, it returns the value that appears first alphabetically.
Example
To demonstrate the MIN function in action, let's examine a practical scenario using a basketball league database where we track player performance metrics. This type of sports analytics has become increasingly sophisticated in professional leagues, with teams relying heavily on statistical analysis for strategic decision-making.
Suppose you need to identify underperforming players in the assists category for coaching evaluation or roster decisions. Using a SQL query with the MIN function, you can quickly pinpoint the player with the fewest assists:
When you execute this query, the database engine processes all assist values and returns the minimum result:
Basketball Statistics Analysis Scenarios
Minimum Assists Query
Find the player with the fewest assists to identify who might need additional training in team play and ball distribution.
Performance Benchmarking
Use minimum values to establish baseline performance metrics and identify areas where the entire team needs improvement.
MIN vs Other Aggregate Functions
| Feature | MIN Function | Other Functions |
|---|---|---|
| Purpose | Find smallest value | Various calculations |
| Return Type | Single minimum value | Depends on function |
| Use Case | Identify lowest performance | Different analysis needs |
MIN Function Best Practices
Ensure the column contains comparable values for meaningful results
MIN function ignores NULL values when calculating the minimum
Find minimum values within specific groups or categories
Apply conditions to find minimums within specific data subsets