SQL Output Prediction

This SQL quiz shows short queries and asks what they return, the way many interviews do. It tests integer division, string concatenation, counting, ON vs WHERE in joins, UNION and the order SQL clauses really run in.

Medium 10 questions ~6 minutes Pass at 80% SQLite

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

What does this print in SQLite?

SELECT 7 / 2;
Show the answer

B. 3 Dividing two integers gives an integer in SQLite and PostgreSQL, so the fraction is cut off. MySQL's / always returns a decimal (3.5000); write 7 / 2.0 or CAST(7 AS REAL) / 2 to get 3.5 everywhere.

What this quiz covers

  • Integer division and string concatenation
  • COUNT(*), COUNT(col) and COUNT(DISTINCT col)
  • WHERE vs HAVING, and filters in ON vs WHERE
  • UNION vs UNION ALL, and text compared as text
  • The logical order of SQL clauses

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.