SQL fluency is useful across many roles. No matter your industry, there’s going to be data stored in databases and SQL is the best way to get to it. Data scientists, in particular, need to be experts in how to quickly access high quality data. While most of us in tech have a decent grasp on the basics, we may lack the opportunities to sharpen those skills in our day-to-day work.
What Is SQLZoo?
In comes SQLZoo — a great place to test your skills and polish 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 to check your answers!
Why Use SQLZoo?
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; there might not always be one right answer.
Within SQLZoo, there’s an educational section, but what you’re looking for are the “Assessments.” These contain more involved examples that allow you to dive deep into a database at varying levels of difficulty. My favorite problems were under the White Christmas challenge which doubled as a good learning experience about the myth of white Christmas (i.e. Christmases are, historically, rarely white!).
Other good challenges to try include Help Desk and Guest House, which both have detailed diagrams explaining the database as well as some more challenging problems.
At some point you might want to make sure 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 not so straightforward as you need to consider readability, speed, efficiency, robustness — all of which matter for businesses, too. 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 me, 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 with which you regularly work.
Finally, there are other platforms out there with similar services to help you learn SQL. A small list:
Best Ways to Practice SQL Queries
- w3resource — This is a great free resource for writing queries.
- The SQL Murder Mystery — This is another one of my favorites thanks to its fun, interactive environment that has you feeling like a top secret agent.
- Interview Query — This platform is dedicated to helping data scientists practice their SQL. If you’re serious, it’s worth looking into, but it’s a paid service.
- TestDome — This is yet another good 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 — mostly because it's not super sexy, or accessible. So, use SQLZoo to practice, test and improve your skills to bring your SQL to the next level.