SQLZoo: The Best Way to Practice SQL
By: Jye Sawtell-Rickson
Tags: Data Science, Sql, Data Analysis, Data Engineering, Data

SQL is a useful skill to have for many roles. No matter the industry, there’s going to be data stored in databases and SQL is the best way to get to it. And Data Scientists, in particular, need to be experts for quick access to high quality data. While most of us in tech have a decent grasp on the basics, we may lack the opportunities to push those skills further in our day-to-day work.

In comes SQLZoo — a great place to test your skills and rebuild rusty ones. You can use it for interview prep, or to stay sharp on the job and impress your boss. Here, I’ll introduce SQLZoo and why you should check it out, as well as a useful link to some SQLZoo answers for double-checking!

SQLZoo is a well established online platform (since 1999) for writing and running SQL queries against a live database. This means you can see the actual result of your query without having to scrupulously check your query matches a solution — it’s the result that matters. This is important because there are often many approaches to difficult questions, with one not necessarily being the best.

They have an educational section, but what you’re looking for are the “Assessments”. These contain more involved examples that allow you to deep-dive into a database at varying levels of difficulty. My favourite problems were under the White Christmas challenge which doubled as a good learning experience for the history of the famous “White Christmas”. Other good ones are Help Desk and Guest House which have detailed diagrams explaining the database as well as some more challenging problems.

At some point you might want to check your SQL looks good, and for that, you can check my solutions for some of the problems on Github (contributions encouraged!). Writing good quality SQL queries is a not so straightforward as you need to consider readability, speed, efficiency, robustness — all of which matter for businesses. While you’re trying out the problems, think about other ways you could have approached them. What would have been a more concise way to write it? How could you have been more efficient? What would happen if some of the columns contained NULL values?

It’s worth noting that SQLZoo is built with a MariaDB Server supporting MySQL. For someone like myself who works mostly with BigQuery’s StandardSQL or PostgreSQL this meant some of the techniques I would normally apply wouldn’t work. This was frustrating at first, but at the same time it’s a good chance to practice other techniques that you might not think of when using the variant of SQL you regularly work with.

Finally, there are other platforms out there with similar services. A small list:

w3resource — another great free resource for writing queries.

The SQL Murder Mystery — another one of my favourites thanks to it’s fun, interactive environment that has you feeling like a top secret agent.

Interview Query — a platform dedicated to data scientists to practice their SQL. If you’re serious worth looking into, but it’s a paid service.

TestDome — another platform for interview practice.

For practicing your general coding skills, there are many great, modern platforms such as Leetcode but SQL is a skill which tends to get less appreciation. Use SQLZoo to practice, test and improve your skills to bring your SQL to the next level.

PS. Let me know if you found any great problems or found some better solutions to mine — happy SQLing!