user157195
user157195

Reputation:

Get the minimum value from a list

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

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

is this possible?

Upvotes: 4

Views: 2722

Answers (2)

Ike Walker
Ike Walker

Reputation: 65537

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

select least(2,4,6,8,1,2,3,4) as result;
+--------+
| result |
+--------+
|      1 |
+--------+

Upvotes: 16

VoodooChild
VoodooChild

Reputation: 9784

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

Upvotes: 1

Related Questions