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
- Employees Earning More Than Their Manager Easy
- Hostel Students Who Never Ordered From the Canteen Easy
- Admitted Patients and Their Ward Beds Easy
- Train Name and Travel Year on Every Booking Easy
- Delivery Captains Leading Five or More Riders Medium
- Costliest Auction Buy of Each Cricket Team Medium
- OTP Verification Rate of Every Account Medium
- Mock Test Sittings for Every Learner and Track Medium
- Daily Cancellation Rate Without Suspended Members Hard
Aggregation
- Mobile Numbers Shared by Wallet Accounts Easy
- Clubs With Enough Members to Register Easy
- Rating Report for Each Canteen Counter Easy
- Average Selling Price of Each Canteen Item Easy
- Share of Quiz Players Who Returned the Next Day Medium
- Students Who Attended Every Fest Workshop Medium
- Monthly Ticket Refund Report by Railway Zone Medium
- Median Delivery Time of Each Restaurant Hard
Subqueries
- Canteen Staff Whose Supervisor Has Left Easy
- Second-Best Innings in the College Cup Medium
- Swap Neighbouring Seats in the Exam Hall Medium
- Student With the Most Study Buddies Medium
- Canteen Menu Prices on 15 March Medium
- Crop Cover for Shared Amounts on Unique Plots Medium
- Top Reviewer and Best-Rated Dish of February Medium
Window Functions
- Faculty Pay Against the Department Average Easy
- Quiz Team Standings With Shared Places Medium
- Readings From a Stuck Cold-Storage Sensor Medium
- Last Rider Into the Ropeway Cabin Medium
- Gym Members' First and Latest Branch Medium
- Cloud Kitchen Seven-Day Moving Average Medium
- Top Three Run Totals in Every League Team Hard
- Busy Streaks at the Book Fair Hard
Strings
Dates
Conditional Logic
New to SQL? Read the DBMS notes first, or test yourself with the SQL skill test.
How it works
- Read the tables. Each problem shows its schema and an example dataset with the result your query should return.
- 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.
- 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.