Joe Celko's SQL Puzzles & Answers

A Collection of SQL Puzzles

Review by SQL-Server-Peformance.Com

Joe Celko’s SQL Puzzles & Answers
By Joe Celko
200 pages. Morgan Kaufmann. $37.95.

Find out more about this book, or purchase it, from

Joe Celko is one of those regulars in online communities about databases about whom people tend to be polarized. Either you like his way of answering questions or you don’t. There doesn’t seem to be much in between.

Fortunately, Joe doesn’t just hang around in database communities, he also writes books. And his books are among the best books about SQL in general. They are full of tips and tricks on how to solve complex problems in an elegant way and unorthodox approaches that might take one, two, or even more readings to understand why they work as they do and why they produce the desired result. I simply love those kinds of books, of which there are only a few around.

One of these “classics,” which will soon be published in its second edition, is “Joe Celko’s SQL Puzzles & Answers.” In it, you will find brainteasers on the following topics:

  • Defining Data.
  • Formatting Data.
  • Selecting Data.
  • Computing Things.
  • Grouping Data.

Because Joe is one of the most vehement advocates of portable ANSI SQL, all solutions presented in the book are naturally coded in ANSI SQL. That means a given solution sometimes cannot be used out-of-the box in SQL Server. But this is another reason why I like Celko’s SQL books so much.

It is always fun to consider how these solutions might be ported to SQL Server or might be improved using the proprietary T-SQL Syntax. And it is exactly this reflection about possible solutions or alternatives in T-SQL that make them an excellent exercise for improving one’s own knowledge and skills. Which, of course, makes Joe’s books on SQL recommendable without restrictions.


Categorized as Books

Leave a comment

Your email address will not be published.