SQL MIN() and MAX()

https://w‮w‬w.theitroad.com

In SQL, the MIN() and MAX() functions are used to find the minimum and maximum values in a column, respectively.

The syntax for the MIN() function is as follows:

SELECT MIN(column_name)
FROM table_name;

For example, suppose we have a table named "sales" with a column named "sale_amount". We can use the MIN() function to find the smallest sale amount in the table, like this:

SELECT MIN(sale_amount)
FROM sales;

This query will return the smallest value in the "sale_amount" column of the "sales" table.

The syntax for the MAX() function is as follows:

SELECT MAX(column_name)
FROM table_name;

For example, suppose we want to find the largest sale amount in the "sales" table. We can use the MAX() function, like this:

SELECT MAX(sale_amount)
FROM sales;

This query will return the largest value in the "sale_amount" column of the "sales" table.

Note that the MIN()