In the last few years I've mainly worked with RoR (Ruby on Rails) projects.

I had few chances to put my hands on SQL queries, and that's pretty common in RoR projects.

RoR uses ActiveRecord to access the DB and developers are pretty happy not to touch SQL code.

In case you don't know, ActiveRecord is a Ruby library that allows you to work with relational SQL Databases, like MySQL and Postgres, without using or even knowing SQL.

After a few years my SQL skills were getting rusty and that became a problem. When I started working for a new FinTech company in London I had to maintain a project that was using a great number of SQL queries.

The good reason for this was:

  • to work efficiently with very big tables containing millions of rows.

  • to create complex reports that makes use of advanced SQL (like partitions and subqueries).

I quickly realised that it was time to (re)learn SQL.

To start I bought an online course on Udemy.
The course was very clear but a bit too basic (I had to set the video speed at 125% for almost the whole course). If you don't know the basic of SQL it is a good course, otherwise find something more challenging.

I also bought an SQL book. After some research I chose "SQL cookbook" (O'Really - Antonio Molinaro).
That was a really good purchase. As expected the book is full of many recipes regarding SQL issues, from very easy ones like
"Select the rows using a certain conditions" to complex issues that are common in data reporting and warehousing.

I really like two things in that book:

  • the recipes that solve certain issues always have a clear explanation present.
  • the solutions of the questions are provided for different SQL Database servers: MySql, Postgress, Oracle and SQL Server.

SQL cookbook is not about learning SQL from scratch, even if it starts with very easy recipes. It is more about to practice SQL. To get the most from the book, before reading the solution, you should try to figure it out yourself.

I really hope you found this post helpful.
Thanks for reading!