Krivalar Tutorials 
Krivalar Tutorials



SQL Min Function - select max sql

<< Previous - SQL Aggregate Functions

Next - SQL MAX() Function >>






SQL - MIN() function

SQL MIN() function gives the minimum value in a column of the table.

SQL - MIN() Syntax

SELECT MIN(column-name) FROM  Table_name
WHERE condition;

SQL MIN Example

Demo student_mark table from collegedb database.

mysql> SELECT * FROM Student_Mark;
+--------+---------+-----------+------+
| RollNo | Name    | City      | Mark |
+--------+---------+-----------+------+
|    101 | Sakthi  | Chennai   |   80 |
|    102 | Bala    | Chennai   |   86 |
|    103 | Chandra | Bangalore |   89 |
|    104 | Madhan  | Goa       |   80 |
|    105 | Jose    | Kerala    |   82 |
|    106 | Jithu   | Kerala    |   85 |
|    107 | Veni    | Bangalore |   85 |
+--------+---------+-----------+------+
7 rows in set (0.00 sec)

Following query statement returns minimum value in the selected column

mysql> SELECT MIN(Mark) FROM Student_Mark;
+-----------+
| MIN(Mark) |
+-----------+
|        80 |
+-----------+
1 row in set (0.01 sec)
mysql> SELECT MIN(Mark) FROM Student_Mark WHERE Mark between 81 and 90;
+-----------+
| min(mark) |
+-----------+
|        82 |
+-----------+
1 row in set (0.00 sec)


<< Previous - SQL Aggregate Functions

Next - SQL MAX() Function >>





Searching using Binary Search Tree