Finding a Minimum with MIN()
Use the aggregate function MIN() to find the minimum of a set of values.
To find the minimum of a set of values:
expr is a column name, literal, or expression. The result has the same data type as expr.
Listing 6.1 and Figure 6.1 show some queries that involve MIN(). The first query returns the price of the lowest-priced book. The second query returns the earliest publication date. The third query returns the number of pages in the shortest history book.
Listing 6.1. Some MIN() queries. See Figure 6.1 for the results.
SELECT MIN(price) AS "Min price"
SELECT MIN(pubdate) AS "Earliest pubdate"
SELECT MIN(pages) AS "Min history pages" FROM titles WHERE type = 'history'; ...