SQL Practice

Practise SQL interview questions in MySQL: joins, GROUP BY, subqueries and window functions on real tables, judged on hidden datasets, with editorials.

Where can I practise SQL interview questions?

CodeKairo's SQL problems are interview-style database questions written in MySQL: each draws its tables, shows an example with the expected result, and judges your query on hidden datasets with empty tables, ties, NULLs and duplicates. They cover the basics, joins, GROUP BY and HAVING, subqueries, window functions, strings, dates and conditional logic, from easy to hard. A failed submission shows the dataset it failed on next to the expected result, and every problem has hints and an editorial with a reference solution. Reading is free without an account; running and submitting need a free account.

47 SQL problems written in MySQL and judged on hidden datasets. Each page draws its tables, shows an example and explains a reference solution.

Basics

Joins

Aggregation

Subqueries

Window Functions

Strings

Dates

Conditional Logic

New to SQL? Read the DBMS notes first, or test yourself with the SQL skill test.

How it works

  1. Read the tables. Each problem shows its schema and an example dataset with the result your query should return.
  2. Write and run. Write one MySQL SELECT in the editor and run it on the examples to see your result next to the expected one.
  3. Submit. A submission runs on every hidden dataset. If a dataset fails, you see its tables, the expected result and yours.

Who it is for

Students preparing for placement SQL rounds and data or backend interviews, and anyone who learnt SQL from a book and wants to write real queries.

Frequently asked questions

Which SQL dialect do I write?
MySQL. Queries run on SQLite behind a MySQL compatibility layer, so MySQL functions such as IF, IFNULL, DATEDIFF, DATE_FORMAT, DATE_ADD with INTERVAL, GROUP_CONCAT with SEPARATOR and window functions all work, and division returns a decimal as it does in MySQL.
How is a query judged?
Your query runs on the examples shown on the page and then on hidden datasets with empty tables, ties, NULLs and duplicates. The result must have the same columns, by name, and the same rows; the order matters only when the problem asks for one.
Can I see why my query failed?
Yes. A failed submission shows the dataset it failed on, the expected result and yours side by side, with a sentence saying what differs — a missing row, a column name, the order.
Is it free?
Yes. Every problem, its tables, its examples and its editorial can be read without an account; sign in to run and submit. A first accepted solve pays 10, 20 or 30 XP by difficulty.