0
0
SQLquery~20 mins

LIMIT vs TOP vs FETCH FIRST syntax in SQL - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Limit Syntax Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
What does this SQL query return?
Consider a table Employees with columns id and name. What will this query return?

SELECT * FROM Employees LIMIT 3;
SQL
SELECT * FROM Employees LIMIT 3;
AAll rows except the first 3
BThe last 3 rows from Employees table
CAn error because LIMIT is not valid SQL
DThe first 3 rows from Employees table
Attempts:
2 left
💡 Hint
LIMIT is used to restrict the number of rows returned starting from the top.
query_result
intermediate
1:30remaining
What is the output of this SQL Server query?
Given the same Employees table, what does this query return?

SELECT TOP 5 * FROM Employees;
SQL
SELECT TOP 5 * FROM Employees;
AThe first 5 rows from Employees table
BThe last 5 rows from Employees table
CSyntax error because TOP is not supported
DAll rows except the first 5
Attempts:
2 left
💡 Hint
TOP is used in SQL Server to limit rows returned.
📝 Syntax
advanced
2:00remaining
Which query uses FETCH FIRST correctly?
Which of these queries correctly limits the result to 4 rows using FETCH FIRST syntax?
ASELECT * FROM Employees FETCH ONLY FIRST 4 ROWS;
BSELECT * FROM Employees FETCH FIRST 4 ROWS ONLY;
CSELECT * FROM Employees FETCH FIRST 4 ROWS;
DSELECT * FROM Employees FETCH 4 ROWS FIRST;
Attempts:
2 left
💡 Hint
The correct syntax is FETCH FIRST number ROWS ONLY.
🔧 Debug
advanced
1:30remaining
Why does this query cause an error?
This query causes an error:

SELECT TOP FROM Employees;

What is the reason?
SQL
SELECT TOP FROM Employees;
ATOP requires a number to specify how many rows to return
BTOP cannot be used without ORDER BY clause
CTOP is not valid in SQL Server
DThe table name is missing
Attempts:
2 left
💡 Hint
TOP must be followed by a number.
🧠 Conceptual
expert
2:00remaining
Which statement about LIMIT, TOP, and FETCH FIRST is true?
Choose the correct statement about LIMIT, TOP, and FETCH FIRST in SQL:
AFETCH FIRST is only used in MySQL
BLIMIT is standard SQL and works in all databases
CTOP is used mainly in SQL Server and requires a number after it
DAll three keywords are interchangeable in any SQL database
Attempts:
2 left
💡 Hint
Think about which database uses TOP and what it requires.