Essential Question: How can I get the maximum and minimum values of a table?
Mastery Objectives:
SWBAT search a SQL table and retrieve the minimum value of that field.
SWBAT search a SQL table and retrieve the maximum value of that field.
Directions: There are two commands that can retrieve the max and min values of a field in a table. Today we will be using a different table called Products because it has numerical fields instead of strings. Strings cannot be used for Min and Max queries. Here is the format:
SELECT MIN(column_name)
FROM table_name
WHERE condition;
SELECT MAX(column_name)
FROM table_name
WHERE condition;
Try the following queries using the min and max commands and take a screen shot and paste them into a google doc and write a description of the results using the SQL editor: https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_max
SELECT MAX(Price) AS LargestPrice FROM Products;
SELECT MIN(Price) AS SmallestPrice FROM Products;
SELECT MAX(SupplierID) FROM Products;
Find the minimum SupplierID from Products
Find the maximum Unit from Products
Find the minimum Unit from Products
Find the maximum ProductID from Products
Find the minimum ProductID from Products