MIP Logo

Analysing names with SQL pt. 2

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here

Introduction

This post picks up from Part 1, where I analysed general name trends and identified a few girl names to help out a friend. In this post, I used subqueries and common table expressions (CTE) to further explore baby name trends in the USA.

6. Subquery: Most picked boy names over the years

I started off with a query that returns boy names with the highest count/frequency every year. I then joined this query into a main query to find out the most picked name overall.

Query:

Result:

 

7. CTE: Which boy name is the all-time favourite?

Now we have the yearly most popular male names. We can clearly see that some names won the most popular seat for more than one year. But which name has accomplished this the most? To do this, I used the query from the task above as a CTE names max_male. From there, I count the names that have appeared the most times.

Query:

Result:

Conclusion

While it may not have been as popular as Liam, Noah, and Jacob in recent years, the name Michael has a longer history of being the most picked out boy name over the century.

Share this post