Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

MIN() - Determine lowest value

Function group: aggregate function

MIN() determines the smallest element in a set of values. NULL values are ignored. Comparing alphanumeric values, national values, numeric values and time values is described in section "Comparison of two rows".


MIN ([ALL | DISTINCT ] expression )



ALL / DISTINCT

ALL or DISTINCT can be specified but has no effect on the result.


expression

Numeric expression, alphanumeric expression, national expression or time value expression (see section "Aggregate functions" for information on restrictions).


Result

If the set of values returned by expression is empty, the result or the result for this group is the NULL value.

Otherwise:

Without GROUP BY clause:

Determines the lowest value in the set of values returned by expression (see "Calculating aggregate functions").

With GROUP BY clause:

Returns the lowest value of each group.


Data type: like expression


Examples

SELECT without GROUP BY:

Query the lowest service price for order 211 in the SERVICE table (result: 50):

SELECT MIN(service_price) FROM service WHERE order_num=211


SELECT with GROUP BY:

Determine the lowest service price for each order number:

SELECT order_num, MIN(service_price) FROM service GROUP BY order_num
   order_num
   200        75
   211        50
   250       125