MIN is an aggregate (and window) function that scans the input set and returns the minimum non-NULL value. If all values are NULL, the result is NULL. MIN works on numeric, date/time, and text data types, following the database’s default collation rules for text. In GROUP BY queries, it produces one result per group. As a window function it can compute running or partitioned minimums without collapsing rows. Because MIN ignores NULL, use COALESCE or FILTER clauses when you need to treat NULL as a real value. DISTINCT inside MIN is legal in most systems but has no practical effect because the minimum of a set is the same whether duplicates exist or not.
expression
(any) - The column or expression whose minimum is soughtDISTINCT
(optional) - Ignored for MIN in most dialects but syntactically allowedPARTITION BY
(optional) - Window partitionsORDER BY
(optional) - Defines row order inside the windowROWS/RANGE
(optional) - Frame specification for windowed minimumMAX, AVG, SUM, COUNT, GROUP BY, HAVING, WINDOW FUNCTIONS
SQL-92 standard
No. MIN ignores NULL values entirely. If every row is NULL, the function returns NULL.
MIN returns the smallest non NULL value, whereas MAX returns the largest. Both share identical syntax.
Yes. Add the OVER clause to calculate running or partitioned minimums without collapsing rows.
Not usually. Since MIN only needs the single smallest value, duplicate rows do not affect the result, making DISTINCT redundant.