SQL final quiz

  • Admin
  • 1 min read

Ten mixed questions covering the whole SQL track, from SELECT to transactions.

SQL

SQL final quiz

10 questions, instant feedback

Question 1 of 10
Question 1 of 10 Which clause order is valid in a SELECT statement?
Why this is the answer

The written order is fixed: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT.

Question 2 of 10
Question 2 of 10 A table has 100 rows and 12 have a NULL email. What does COUNT(email) return?
Why this is the answer

COUNT(column) counts non-null values, so 100 minus 12 nulls is 88.

Question 3 of 10
Question 3 of 10 Which query lists categories with more than five products?
Why this is the answer

Group first, then filter groups with HAVING. Aggregate functions cannot appear in WHERE.

Question 4 of 10
Question 4 of 10 Which join finds customers who have never ordered?
Why this is the answer

A left join keeps every customer; filtering for NULL order ids keeps only those without a match.

Question 5 of 10
Question 5 of 10 What does ROLLBACK do?
Why this is the answer

ROLLBACK undoes every statement since the transaction began, or since the last savepoint.

Question 6 of 10
Question 6 of 10 Which column type best stores a boolean flag in SQLite?
Why this is the answer

SQLite has no boolean type; INTEGER with CHECK (flag IN (0, 1)) is the usual approach.

Question 7 of 10
Question 7 of 10 What is the main risk of SELECT * in application code?
Why this is the answer

Naming columns makes the contract explicit, so adding a column does not change what the code receives.

Question 8 of 10
Question 8 of 10 Why can LIMIT without ORDER BY return different rows each run?
Why this is the answer

Without an explicit order the engine may return rows in any sequence, so the first N rows are not well defined.

Question 9 of 10
Question 9 of 10 Which change adds an index on orders.customer_id?
Why this is the answer

CREATE INDEX names the index and the table, then lists the indexed columns.

Question 10 of 10
Question 10 of 10 A query joining three tables returns duplicated rows. What is the usual cause?
Why this is the answer

Joining a parent to several children multiplies rows. Aggregate with GROUP BY, or join a pre-aggregated subquery.

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