SQL SELECT MIN, MAX Statement
- SELECT MIN returns the minimum value for a column.
- SELECT MAX returns the maximum value for a column.
The SQL SELECT MIN and MAX syntax
The general MIN syntax is:
- SELECT MIN(column-name) FROM table-name
The general MAX syntax is:
- SELECT MAX(column-name) FROM table-name
SQL SELECT MAX and MIN Examples
1) Example of MIN statement
mysql> select min(age) from person;
+----------+
| min(age) |
+----------+
| 18 |
+----------+
1 row in set (0.00 sec)
2) Example of MAX Statement
mysql> select max(age) from person;
+----------+
| max(age) |
+----------+
| 26 |
+----------+
1 row in set (0.00 sec)
mysql> select max(age) from person;
+----------+
| max(age) |
+----------+
| 26 |
+----------+
1 row in set (0.00 sec)
Comments
Post a Comment