0
0
MySQLquery~5 mins

MIN and MAX functions in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the MIN() function do in SQL?
The MIN() function returns the smallest value from a column or expression in a set of rows.
Click to reveal answer
beginner
What does the MAX() function do in SQL?
The MAX() function returns the largest value from a column or expression in a set of rows.
Click to reveal answer
intermediate
How do MIN() and MAX() functions handle NULL values?
MIN() and MAX() ignore NULL values when calculating the smallest or largest value.
Click to reveal answer
beginner
Write a SQL query to find the minimum and maximum price from a products table.
SELECT MIN(price) AS LowestPrice, MAX(price) AS HighestPrice FROM products;
Click to reveal answer
intermediate
Can MIN() and MAX() be used with GROUP BY? What does it do?
Yes, they can be used with GROUP BY to find the smallest or largest value within each group of rows.
Click to reveal answer
What will the query SELECT MIN(age) FROM users; return?
AThe total number of users
BThe oldest age in the users table
CThe average age in the users table
DThe youngest age in the users table
If a column contains NULL values, how do MIN() and MAX() treat them?
AThey ignore NULL values
BThey count NULL as zero
CThey return NULL if any NULL exists
DThey treat NULL as the smallest value
Which SQL clause is used with MIN() and MAX() to get results per category?
AORDER BY
BGROUP BY
CWHERE
DHAVING
What does this query return? SELECT MAX(salary) FROM employees;
AThe highest salary
BThe lowest salary
CThe average salary
DThe number of employees
Can MIN() and MAX() be used on text columns?
ANo, only numbers
BOnly MAX() works on text
CYes, they return alphabetically smallest and largest values
DOnly MIN() works on text
Explain how MIN() and MAX() functions work in SQL and give an example query.
Think about finding lowest and highest values in a list.
You got /4 concepts.
    Describe how you would find the highest and lowest prices for each product category using MIN() and MAX().
    Grouping helps find min and max per group.
    You got /3 concepts.