MIN() function: It returns the minimum(smallest) value of the selected column.
Syntax:
SELECT MIN(column_name)
FROM table_name
WHERE condition; DEMO STUDENTS TABLE:
| Roll_No | Name | Marks |
| 1 | Dev | 35 |
| 2 | Ayush | 45 |
| 3 | Ram | 55 |
| 4 | Pyush | 65 |
| 5 | Nazim | 75 |
Example: To fetch the lowest marks form the students table.
SELECT MIN(marks)
FROM students; This will fetch the values as shown below:
| Roll_No | Name | Marks |
| 1 | Dev | 35 |
MAX() function: It returns the maximum(highest) value of the selected column.
Syntax:
SELECT MAX(column_name)
FROM table_name
WHERE condition; Example: To fetch the highest marks form the students table.
SELECT MAX(marks)
FROM students; This will fetch the values as shown below:
| Roll_No | Name | Marks |
| 5 | Nazim | 75 |