mySql  min function

the mysql min function returns the smallest value of the selected column.

mysql min() syntax

         select    min(column_name or expre)    from   table_name;

the min() function returns null if there is no matching row.

demo database table use in the below min function example

below is a selection from the "users" table:

useridfirstnamesalarybonus
1sandeep10,0001000
2ankit20,0002000
3ram30,0003000
4vikram12,0002000

mysql min function example

the following mysql statement gets the smallest value of the "bonus" column from the "users" table:

               
               select    min(bonus)    as   min_bonus      from    users;

output :

min_bonus
1000

when you combine the min function with the group by clause in a select statement, you can get the minimum values for every group.