Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the minimum value from a list

Tags:

mysql

I want to get the minimum of a list of numbers in MYSQL

select min(1,9,20,..);

is this possible?


2 Answers

The function you are looking for is called LEAST():

select least(2,4,6,8,1,2,3,4) as result;
+--------+
| result |
+--------+
|      1 |
+--------+
like image 134
Ike Walker Avatar answered Oct 19 '25 01:10

Ike Walker


Yes it is possible

SELECT MIN( mark ) FROM `student`

given that you have a student table with a mark column in it.

or use Least as posted by @Ike Walker

like image 43
VoodooChild Avatar answered Oct 19 '25 01:10

VoodooChild



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!