Reading data quiz

  • Admin
  • 1 min read

Nine questions on SELECT, WHERE, ORDER BY, LIMIT, NULL and comparison operators.

SQL

Reading data quiz

9 questions, instant feedback

Question 1 of 9
Question 1 of 9 Which clause chooses the columns a query returns?
Why this is the answer

SELECT lists the columns or expressions to return. FROM names the table they come from.

Question 2 of 9
Question 2 of 9 What does SELECT * return?
Why this is the answer

The asterisk means all columns. It is convenient while exploring and risky in application code, where a schema change can break assumptions.

Question 3 of 9
Question 3 of 9 Which operator matches a pattern?
Why this is the answer

LIKE compares text against a pattern where % matches any run of characters and _ matches one character.

Question 4 of 9
Question 4 of 9 Which clause is evaluated before GROUP BY?
Why this is the answer

WHERE filters individual rows before grouping. HAVING filters groups after aggregation.

Question 5 of 9
Question 5 of 9 What does ORDER BY price DESC do?
Why this is the answer

DESC reverses the default ascending order, so the highest price comes first.

Question 6 of 9
Question 6 of 9 Which statement about NULL is correct?
Why this is the answer

NULL represents an unknown value, so comparisons with = return unknown rather than true. Use IS NULL or IS NOT NULL.

Question 7 of 9
Question 7 of 9 What does LIMIT 10 OFFSET 20 return?
Why this is the answer

OFFSET skips twenty rows and LIMIT then returns ten. Without ORDER BY the skipped rows are not guaranteed to be stable.

Question 8 of 9
Question 8 of 9 Which query finds rows where city is either Pune or Delhi?
Why this is the answer

IN checks membership in a list. Using AND with two different values for the same column matches nothing.

Question 9 of 9
Question 9 of 9 Why is ORDER BY needed for reliable pagination?
Why this is the answer

A database may return rows in any order without ORDER BY, so LIMIT/OFFSET pages can repeat or skip rows. Add a unique tiebreaker such as the id.

Your answers stay in this browser. Nothing is sent to a server.