Learn With Grito

MIN in SQL — The Complete Guide for Data Analysts

MIN identifies the smallest value in a dataset. Learn how data analysts use it for inventory monitoring, risk detection, and business baseline analysis.

Tutorial Series10 Mins ReadSQL Level 2

Imagine you're working as a Data Analyst at Grito Commerce, and your manager asks:

  • "What was the lowest order value this month?"
  • "Which product has the lowest inventory?"
  • "When was the earliest customer signup?"

"What is the minimum salary in the Sales department?"

These questions aren't asking for totals or averages.

They're asking for the smallest value.

That's exactly what the SQL MIN function is designed to find.

This is the fourth article in the SQL Aggregation cluster and builds upon the SQL Aggregate Functions hub, COUNT, SUM, and AVG. While the previous functions measure quantity, totals, and averages, MIN helps identify the lowest value in a dataset.

Throughout this SQL series, we'll continue using the Grito Commerce database with tables like Orders, Customers, Products, Inventory, Employees, Departments, Payments, and Campaigns.

AI Answer Block MIN is an SQL aggregate function that returns the smallest non-NULL value from a numeric, date, or text column. Data analysts use it to identify the lowest amount, earliest date, minimum inventory level, shortest delivery time, or any other minimum value in business data.

Why MIN matters

Businesses constantly monitor minimum values because they often indicate risk, opportunity, or operational issues.

  • Examples include:
  • Lowest inventory level
  • Lowest daily revenue
  • Earliest customer signup
  • Cheapest product
  • Minimum employee salary

Shortest delivery time

Finding the minimum value helps businesses identify boundaries rather than averages or totals.

What MIN does

MIN returns the smallest value from the selected column.

Unlike COUNT, SUM, or AVG, it doesn't summarize many values into a calculation.

  • Instead, it finds the single smallest value.
  • It works with:
  • Numbers
  • Dates
  • Date & Time values
  • Text values (alphabetically)

The core idea behind MIN

  • Imagine inventory quantities.
  • 80
  • 120
  • 35
  • 60

200

  • Instead of calculating totals,
  • MIN identifies

35

  • The business immediately knows:

"This product is closest to running out."

That makes MIN an excellent operational monitoring function.

Visual Framework

Many Values

MIN()

Smallest Value

Business Alert / Decision

Unlike averages,

minimum values often highlight exceptions rather than normal performance.

  • MIN syntax
  • Basic syntax
  • MIN(column_name)

Example

SQL Query
SELECT MIN(order_total)
FROM Orders;
Business question answered
"What was the smallest order value?"
How MIN works
Suppose the Orders table contains
Order
Amount
101
₹2,000
102
₹6,500
103
₹800
104
₹3,200
Running
SELECT MIN(order_total)
FROM Orders;
returns
800
The smallest order value.
MIN with numbers
The most common use case.
Examples
Lowest salary
Lowest price
Lowest stock quantity
Lowest revenue
Minimum discount
Example
SELECT MIN(product_price)
FROM Products;
Business question
"What is our cheapest product?"
MIN with dates
Many beginners don't realize that MIN also works with dates.
Example
SELECT MIN(order_date)
FROM Orders;
Business question
"When was the first order placed?"
The smallest date is simply the earliest date.
This is widely used in customer lifecycle analysis.
MIN with text
MIN can also work with text columns.
Example
SELECT MIN(customer_name)
FROM Customers;
SQL returns the alphabetically smallest value.
Although technically valid,
this use case is much less common in analytics.
Business reporting usually focuses on numeric and date values.
MIN with GROUP BY
This is where MIN becomes much more useful.
Example
SELECT department_name,
MIN(employee_salary) AS lowest_salary
FROM Employees
GROUP BY department_name;
Business question
"What is the lowest salary in each department?"
Instead of one answer,
you receive one minimum value for every department.
Practical Business Examples
Example 1 — Lowest Product Price
SELECT MIN(product_price)
FROM Products;
Business question
"What is our least expensive product?"
Example 2 — Earliest Customer Signup
SELECT MIN(signup_date)
FROM Customers;
Business question
"When did the earliest customer register?"
Example 3 — Lowest Inventory Level
SELECT MIN(stock_quantity)
FROM Inventory;
Business question
"Which inventory level is currently the lowest?"
Example 4 — Lowest Salary by Department
SELECT department_id,
MIN(employee_salary)
FROM Employees
GROUP BY department_id;
Business question
"What's the minimum salary in every department?"
Example 5 — Earliest Order Date by Customer
SELECT customer_id,
MIN(order_date)
FROM Orders
GROUP BY customer_id;
Business question
"When did each customer place their first order?"
This is commonly used in retention and customer lifecycle analysis.
MIN with WHERE
WHERE filters the data before SQL finds the minimum value.
Example
SELECT MIN(order_total)
FROM Orders
WHERE order_status='Completed';
Business question
"What was the smallest completed order?"
Cancelled orders are excluded.
MIN with HAVING
Example
SELECT category_id,
MIN(product_price)
FROM Products
GROUP BY category_id
HAVING MIN(product_price) < 1000;
Business question
"Which product categories contain products priced below ₹1,000?"
MIN and NULL values
MIN ignores NULL values.
Example
Values
100
300
NULL
50
Result
50
NULL is ignored.
It is never treated as zero.
Common Business Use Cases
Operations
Lowest inventory
Fastest delivery
Finance
Minimum payment
Lowest transaction
HR
Minimum salary
Earliest joining date
Sales
Lowest order value
Cheapest product
Customer Analytics
First purchase date
Earliest signup
MIN vs MAX
Many beginners confuse these functions.
Function
Purpose
MIN
Finds the smallest value
MAX
Finds the largest value
Example
Lowest salary
↓
MIN
Highest salary
↓
MAX
Together,
they help define the range of business performance.
MIN vs ORDER BY
Another common confusion.
Suppose you want the lowest value.
Two approaches exist.
Approach 1
SELECT MIN(order_total)
FROM Orders;
Approach 2
SELECT order_total
FROM Orders
ORDER BY order_total ASC
LIMIT 1;
Both return the smallest value.
However,
MIN communicates your intention much more clearly.
If you only need the minimum value,
MIN is usually the better choice.
Performance Considerations
MIN is generally very efficient.
On indexed columns,
many databases can identify the minimum value without scanning every row.
This makes MIN particularly useful on large production datasets.
Common Mistakes
1. Using MIN when the entire row is needed
MIN returns only the minimum value.
It does not automatically return the complete record associated with that value.
2. Assuming NULL affects the minimum
NULL values are ignored.
3. Confusing earliest and latest dates
Remember
Earliest
↓
MIN
Latest
↓
MAX
4. Using ORDER BY unnecessarily
If you only need one minimum value,
MIN is simpler and usually more efficient.
5. Forgetting GROUP BY
Without grouping,
SQL returns one overall minimum.
If you need one minimum per department, city, or category,
use GROUP BY.
Real Analyst Workflow
Imagine the Operations Manager asks:
"Which warehouse is closest to running out of stock?"
Your thought process becomes:
We need the smallest stock quantity.
Use MIN.
Decide whether grouping is needed.
Filter inactive warehouses if necessary.
Deliver the lowest inventory values.
This type of query is common in inventory management and supply chain analytics.
Analyst Tip
Don't stop after finding the minimum value.
Always ask why it is the minimum.
For example, finding the lowest inventory level is useful, but understanding whether it is caused by high demand, delayed suppliers, or incorrect forecasting is what creates real business value.
The Grito Factor
Many fraud detection systems use minimum values in unexpected ways. For example, an unusually small payment amount—such as ₹1—can indicate a card validation attempt before a larger fraudulent transaction. Sometimes the smallest values reveal the biggest problems.
Interview Perspective
Interviewers often combine MIN with dates, grouping, and filtering.
Common questions include:
Difference between MIN and ORDER BY ... LIMIT 1.
How does MIN handle NULL values?
Find the earliest customer signup.
Find the minimum salary by department.
Return only categories where the minimum product price is below a threshold.
These questions test SQL fundamentals as well as business reasoning.
Practice Questions
Beginner
Which SQL function finds the smallest value?
Does MIN consider NULL values?
Intermediate
Find the earliest order date for each customer.
Calculate the minimum salary for every department.
Advanced
Show only product categories where the minimum product price is less than ₹500.
(Hint: Combine MIN, GROUP BY, and HAVING.)
Final Thoughts
MIN is a simple function, but it answers some of the most important operational questions in business.
Whether you're identifying the earliest customer, the cheapest product, the lowest inventory level, or the minimum salary, MIN helps analysts monitor boundaries, detect exceptions, and uncover situations that need attention.
Learning MIN also prepares you for more advanced analytical patterns where identifying extremes becomes an essential part of business decision-making.
Continue Your Learning
Next lessons in this cluster:
MAX
SQL Grouped Analysis Examples
Related lessons:
SQL Aggregate Functions
COUNT
SUM
AVG
GROUP BY
HAVING
ORDER BY
The next lesson explores MAX, where you'll learn how businesses identify the highest values, latest events, and peak performance across their data.

Continue learning

Grit Over Excuses.

— The Grito Team