Challenge - 5 Problems
Built-in Functions Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Using built-in functions to calculate averages
Given a table Sales with a column
amount, what is the output of this query?SELECT AVG(amount) FROM Sales;
SQL
CREATE TABLE Sales(amount INT); INSERT INTO Sales VALUES (100), (200), (300);
Attempts:
2 left
💡 Hint
Think about what the AVG function does with the numbers in the column.
✗ Incorrect
The AVG function calculates the average value of the column. Here, (100 + 200 + 300) / 3 = 200.
📝 Syntax
intermediate2:00remaining
Identifying syntax error with built-in functions
Which option will cause a syntax error when trying to convert a string to uppercase in SQL?
Attempts:
2 left
💡 Hint
Check the correct syntax for calling functions in SQL.
✗ Incorrect
Functions in SQL use parentheses (), not square brackets []. Option A uses brackets causing a syntax error.
❓ query_result
advanced2:00remaining
Effect of built-in functions on NULL values
Consider a table Employees with a column
salary containing values (5000, NULL, 7000). What is the result of this query?SELECT SUM(salary) FROM Employees;
SQL
CREATE TABLE Employees(salary INT); INSERT INTO Employees VALUES (5000), (NULL), (7000);
Attempts:
2 left
💡 Hint
Think about how SUM treats NULL values in SQL.
✗ Incorrect
SUM ignores NULL values and adds only the non-null salaries: 5000 + 7000 = 12000.
❓ optimization
advanced2:00remaining
Choosing built-in functions for date extraction
You want to extract the year from a date column
order_date. Which query is the most efficient and correct in standard SQL?Attempts:
2 left
💡 Hint
Consider which function is standard SQL and widely supported.
✗ Incorrect
EXTRACT(YEAR FROM ...) is the standard SQL function for extracting year. Others are dialect-specific.
🧠 Conceptual
expert2:00remaining
Why built-in functions improve database performance
Which statement best explains why using built-in functions in SQL queries improves performance compared to user-defined functions?
Attempts:
2 left
💡 Hint
Think about how databases handle built-in vs user-defined functions internally.
✗ Incorrect
Built-in functions are pre-compiled and optimized by the database engine, making them faster and more efficient.