ID EN
Aggregate Functions

MIN([DISTINCT] expr) [over_clause]

MySQL 8.4

MIN([DISTINCT] expr) [over_clause]

Syntax

MYSQL
SELECT student_name, MIN(test_score), MAX(test_score)
       FROM student
       GROUP BY student_name;

Examples

Example

Returns the minimum value of expr. MIN() may take a string argument; in such cases, it returns the minimum string value. See Section 10.3.1, “How MySQL Uses Indexes”. The DISTINCT keyword can be used to find the minimum of the distinct values of expr, however, this produces the same result as omitting DISTINCT.

MYSQL
SELECT student_name, MIN(test_score), MAX(test_score)
       FROM student
       GROUP BY student_name;