This directory contains my collection of SQL puzzles. I hope you enjoy these puzzles as much as I have enjoyed creating them!
To get started, download the Advanced SQL Puzzles.pdf.
⌨️ The solutions provided are written in Microsoft SQL Server T-SQL, but you can easily modify them to fit your flavor of SQL.
❓ If you have any questions, please feel free to create a GitHub discussion. I am always happy to help out and explain different solutions.
As my list of puzzles continues to grow, I have decided to combine the puzzles into one single PDF document broken down into two different sections.
-
In the first section I have 64 of the most difficult puzzles that I could create; randomly organized and in no specific order. These are mostly set-based puzzles, interspersed with a small number of puzzles that require knowledge of constraints, specific data types, cursors, loops, etc....
-
In the second set of puzzles, I have collected all the puzzles related to permutations, combinations, and sequences. Solving these puzzles will require a deeper knowledge of your SQL thinking, focusing on such constructs as using recursion or sequence objects to reach the desired output
To get started, download the Advanced SQL Puzzles.pdf.
- Solutions are provided in the
Advanced SQL Puzzles Solutions.sqlscript - If you just want the
CREATE TABLEandINSERTstatements without the solutions, see the scriptAdvanced SQL Puzzles DDL.sql. - Solutions for the more advanced second set of puzzles are located in the directory
Part II. - I also keep my collection of SQL statements using recursion in the directory
Recursion Examples. Here you can find out how to solve Markov chains, solve the Traveling Salesman problem, calculate floor and ceiling caps, or find a solution to a Sudoku puzzle.
📫 If you find any inaccuracies, misspellings, bugs, dead links, etc. please report an issue! No detail is too small, and I appreciate all the help.
😄 Happy coding!
I hope you find this repository to be useful and informative and I welcome any new puzzles or tips and tricks you may have. I also have a Wordpress site where you can find my data analytics projects, Python puzzles, and blog.