Challenge - 5 Problems
MIN and MAX Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Find the minimum salary in the Employees table
Given the Employees table with columns id, name, and salary, what is the result of this query?
SELECT MIN(salary) FROM Employees;
MySQL
CREATE TABLE Employees (id INT, name VARCHAR(50), salary INT); INSERT INTO Employees VALUES (1, 'Alice', 5000), (2, 'Bob', 7000), (3, 'Charlie', 6000);
Attempts:
2 left
💡 Hint
MIN returns the smallest value in the column.
✗ Incorrect
The smallest salary among 5000, 7000, and 6000 is 5000.
❓ query_result
intermediate2:00remaining
Find the maximum age in the Users table
Given the Users table with columns user_id, username, and age, what is the output of this query?
SELECT MAX(age) FROM Users;
MySQL
CREATE TABLE Users (user_id INT, username VARCHAR(50), age INT); INSERT INTO Users VALUES (1, 'john', 25), (2, 'jane', 30), (3, 'doe', 28);
Attempts:
2 left
💡 Hint
MAX returns the largest value in the column.
✗ Incorrect
The largest age among 25, 30, and 28 is 30.
📝 Syntax
advanced2:00remaining
Identify the syntax error in using MIN function
Which option contains a syntax error when trying to find the minimum price from the Products table?
MySQL
CREATE TABLE Products (product_id INT, product_name VARCHAR(50), price DECIMAL(10,2)); INSERT INTO Products VALUES (1, 'Pen', 1.20), (2, 'Notebook', 2.50), (3, 'Eraser', 0.80);
Attempts:
2 left
💡 Hint
MIN function requires parentheses around the column name.
✗ Incorrect
Option A misses parentheses around price, causing a syntax error.
❓ query_result
advanced2:00remaining
Find the maximum and minimum scores in one query
Given the Scores table with columns student_id and score, what is the output of this query?
SELECT MAX(score) AS max_score, MIN(score) AS min_score FROM Scores;
MySQL
CREATE TABLE Scores (student_id INT, score INT); INSERT INTO Scores VALUES (1, 88), (2, 92), (3, 75), (4, 92), (5, 60);
Attempts:
2 left
💡 Hint
MAX and MIN can be selected together in one query.
✗ Incorrect
The highest score is 92 and the lowest is 60.
🧠 Conceptual
expert2:30remaining
Understanding MIN and MAX with NULL values
Consider the table Measurements with a column value that contains some NULLs. What will the query
SELECT MIN(value), MAX(value) FROM Measurements;return?
MySQL
CREATE TABLE Measurements (value INT); INSERT INTO Measurements VALUES (10), (NULL), (5), (NULL), (20);
Attempts:
2 left
💡 Hint
MIN and MAX ignore NULL values in aggregation.
✗ Incorrect
MIN and MAX ignore NULLs and return the smallest and largest non-null values.