0
0
SQLquery~5 mins

MIN and MAX functions in SQL - 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 in a table.
Click to reveal answer
beginner
What does the MAX() function do in SQL?
The MAX() function returns the largest value from a column in a table.
Click to reveal answer
intermediate
Can MIN() and MAX() be used with text columns?
Yes, MIN() and MAX() can be used with text columns. They return the smallest or largest value based on alphabetical order.
Click to reveal answer
intermediate
How do MIN() and MAX() behave with 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 highest salary from an 'employees' table.
SELECT MAX(salary) AS highest_salary FROM employees;
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 youngest age in the users table
DThe average age of users
Which SQL function returns the largest value in a column?
AMAX()
BMIN()
CSUM()
DCOUNT()
If a column contains NULL values, how do MIN() and MAX() treat them?
AThey include NULLs in the result
BThey ignore NULLs
CThey return NULL
DThey cause an error
What does SELECT MAX(name) FROM customers; return if 'name' is a text column?
AThe alphabetically last name
BThe longest name
CThe alphabetically first name
DThe shortest name
Which of these queries finds the smallest price in a 'products' table?
ASELECT MAX(price) FROM products;
BSELECT COUNT(price) FROM products;
CSELECT SUM(price) FROM products;
DSELECT MIN(price) FROM products;
Explain how the MIN() and MAX() functions work in SQL and give an example of each.
Think about finding lowest and highest values in a list.
You got /4 concepts.
    Describe how NULL values affect the results of MIN() and MAX() functions in SQL.
    Consider what happens if some data is missing.
    You got /3 concepts.