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 from employees
Given the table Employees with columns
id, name, and salary, what is the result of this query?SELECT MIN(salary) FROM Employees;
SQL
SELECT MIN(salary) FROM Employees;
Attempts:
2 left
💡 Hint
MIN function finds the smallest value in a column.
✗ Incorrect
The MIN function returns the smallest value in the specified column. Here, it returns the smallest salary among all employees.
❓ query_result
intermediate2:00remaining
Find the maximum order amount
Given the table Orders with columns
order_id, customer_id, and amount, what does this query return?SELECT MAX(amount) FROM Orders;
SQL
SELECT MAX(amount) FROM Orders;
Attempts:
2 left
💡 Hint
MAX function finds the largest value in a column.
✗ Incorrect
The MAX function returns the highest value in the specified column. Here, it returns the largest order amount.
🧠 Conceptual
advanced2:00remaining
Understanding MIN and MAX with NULL values
Consider a table Scores with a column
score that contains some NULL values. What will the query SELECT MIN(score) FROM Scores; return?Attempts:
2 left
💡 Hint
Aggregate functions ignore NULL values by default.
✗ Incorrect
MIN and MAX ignore NULL values and return the smallest or largest non-NULL value respectively.
📝 Syntax
advanced2:00remaining
Identify the syntax error in MIN usage
Which of the following SQL queries will cause a syntax error?
Attempts:
2 left
💡 Hint
Aggregate functions require parentheses around the column name.
✗ Incorrect
Option C is missing parentheses around the column name, causing a syntax error.
❓ optimization
expert3:00remaining
Optimizing MIN and MAX queries on large tables
You have a very large table Sales with millions of rows and a column
sale_date. You want to find the earliest and latest sale dates efficiently. Which approach is best?Attempts:
2 left
💡 Hint
Indexes help speed up queries that search for minimum or maximum values.
✗ Incorrect
Creating an index on the column allows the database to quickly find the minimum and maximum values without scanning the entire table.