SQL MIN( ) Function



The MIN()  Function

The MIN() function returns the smallest value of the selected column.

SQL MIN() Syntax

SELECT MIN(column_name) FROM table_name

SQL MIN()  Example

We have the following "result" table:
Student_No
Subject_No
Year_Exam
Marks
ST101
SU03
1
69
ST102
SU01
1
61
ST101
SU04
1
70
ST101
SU05
1
87
ST103
SU01
2
51
ST103
SU03
1
59
ST103
SU01
3
56
ST108
SU01
1
78
ST105
SU05
2
98


Now we want to find the Minimum  value of the "Marks" column.
We use the following SQL statement:

SELECT MIN(Marks) AS MIN_Marks FROM result;

The result-set will look like this:

MIN_Marks
51

No comments:

Post a Comment