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. 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 generating a calendar table. 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 advanced join theory topics. It’s a great resource to learn the inner working of SQL joins.

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

Here is where I keep the various data analytic projects that I have done. This mostly includes descriptive and inferential statistical projects I’ve created, plus some machine learning models that I have built.

Data Analytics

Copy and Paste

I finally got smart and created a page where I can easily copy the SQL statements that I routinely use. It’s a growing list, and I really need to spend some time to add all my scripts and make it tidy.

Copy and Paste


I also keep a small blog here. Right now, it’s pretty sparse, but I plan to keep adding to it, hopefully.


Happy coding!!