Welcome to my SQL puzzle website. I hope you enjoy solving these puzzles as much as I have enjoyed creating them.

Link to my GitHub repository below:


All solutions to the puzzles are written in SQL Server’s T-SQL, but you can easily adapt the solutions to your flavor of SQL.

I’m constantly adding new material, so scroll through to find all sorts of database tips, tricks, and insights.

Check out the blog portion of this WordPress site as well. Right now, it’s pretty sparse.

I also welcome any corrections, new tricks and techniques, dead links, misspellings, bugs, and any new puzzles you think would be great for this blog.

Let’s get on to the puzzles….

SQL Puzzles

Here are 50+ of the most difficult set-based SQL puzzles that I could write, nicely condensed into a PDF file. This is a great starting point to determine your level of expertise with SQL. I highly recommend developers of all skill levels work through this puzzle set; you may be surprised.

Advanced SQL Puzzles

Python Puzzles

I also started a WordPress page of Python puzzles. These are mostly probability puzzles where you perform hacker statistics.

Python Puzzles

Tips and Tricks

Here are some additional resources for finding new tips, tricks and insights that will help you in your journey.

Creating a Calendar Table

My code for creating a table valued function for use in generating calendar tables. Once understood, I hope you find the table valued function to be more beneficial than the usual static calendar table.

Pivoting Data

If you find the pivot table syntax to be a little frustrating, here you can implement a function to parameterize the pivot syntax. Very useful if you find yourself having to write a lot of pivot statements.

Data Profiling

A robust SQL script to perform data profiling on a table using dynamic sql. The script can be used to quickly find minimum and maximum values, if NULLs or empty strings appear in the data, etc… I wouldn’t recommend this script on large tables, but its simple to us; just change the table name variable in the script.

Subtracting Two Dates

Anyone who has used SQL Server’s date difference functions know they are severely limiting. Here I have a couple of functions (one table valued and one scalar) that can accurately subtract two dates.

Database Writings

In this repository you will find my musing and writings on various database topics.

Database Concepts and Components

Here I have collected all the different database concepts, components, and aspects into one
document; formatted into a list of questions with a link to an online resource (which is mostly the
Wikipedia article on the subject) covering the subject.

Advanced SQL Joins

A great document that covers the advanced join theory topics. Great for novices to understand the inner workings of joins, and more advanced developers are sure to learn some things along the way as well.

Behavior of Nulls

Null markers are a great source of frustration, so I decided to write a whole document about how the various SQL constructs treat the NULL marker.

Data Analytics

I also keep a WordPress site of my data analytic projects.

Data Analytics

Happy coding!