MIN

Description

Aggregate function.

The MAX() function calculates the maximum value across a group of values.

Syntax

1. > MIN(expr)

Arguments

Arguments Description
expr Any expression

Returned Value

Returns the minimum value of expr. MIN() may take a string argument, in such cases, it returns the minimum string value.

Examples

1. > drop table if exists tbl1,tbl2;
2. > create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);
3. > insert into tbl1 values (0,1,1,7,"a");
4. > insert into tbl1 values (0,1,2,8,"b");
5. > insert into tbl1 values (0,1,3,9,"c");
6. > insert into tbl1 values (0,1,4,10,"D");
7. > insert into tbl1 values (0,1,5,11,"a");
8. > insert into tbl1 values (0,1,6,12,"c");

10. > select min(col_1d) from tbl1;
11. +-------------+
12. | min(col_1d) |
13. +-------------+
14. |           7 |
15. +-------------+

17. > select min(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;
18. +------+
19. | m1   |
20. +------+
21. |    1 |
22. |    2 |
23. |    3 |
24. |    4 |
25. +------+