Posts

Showing posts with the label min

SQL MIN function

SQL MIN function Description The SQL MIN function is used to return the minimum value of an expression in a SELECT statement. Syntax The syntax for the SQL MIN function is: SELECT MIN( expression ) FROM tables WHERE conditions; Parameters or Arguments expression can be a numeric field or formula. Example - With Single expression The simplest way to use the SQL MIN function would be to return a single field that calculates the MIN value. For example, you might wish to know the minimum salary of all employees.   SELECT MIN(salary) AS "Lowest salary" FROM employees; In this SQL MIN function example, weve aliased the MIN(salary) field as "Lowest salary". As a result, "Lowest salary" will display as the field name when the result set is returned. Example - Using SQL GROUP BY In some cases, you will be required to use the SQL GROUP BY clause with the SQL MIN function. For example, you could also use the SQL MIN function to return the name of each d...