Jump to ratings and reviews
Rate this book

Joe Celko's SQL for Smarties: Advanced SQL Programming Third Edition

Rate this book
SQL for Smarties was hailed as the first book devoted explicitly to the advanced techniques needed to transform an experienced SQL programmer into an expert. Now, 10 years later and in the third edition, this classic still reigns supreme as the book written by an SQL master that teaches future SQL masters. These are not just tips and techniques; Joe also offers the best solutions to old and new challenges and conveys the way you need to think in order to get the most out of SQL programming efforts for both correctness and performance. In the third edition, Joe features new examples and updates to SQL-99, expanded sections of Query techniques, and a new section on schema design, with the same war-story teaching style that made the first and second editions of this book classics.

840 pages, Paperback

First published January 1, 1995

38 people are currently reading
423 people want to read

About the author

Joe Celko

28 books16 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
68 (33%)
4 stars
76 (37%)
3 stars
42 (20%)
2 stars
11 (5%)
1 star
4 (1%)
Displaying 1 - 16 of 16 reviews
Profile Image for Mike Polsky.
14 reviews16 followers
December 26, 2019
I found it an easy read, common sense and with numerous useful examples. I won't offer up the cliche that more deveolpers should read this book but will offer up the suggestion that more of them follow up by implementing it's suggestions.Really ENJOYED it, it was surprisingly easy to read. Explained all the rules and principles well. I was thinking about our production code all the time while reading it.
Profile Image for Bernie Noel.
20 reviews13 followers
September 19, 2019
A must-read for every programmer! Most of the BOOKS teach you how to program, or how to use your specific language features, but none of them will teach you how to actually write clean and manitainable code. This one does!
174 reviews4 followers
July 20, 2017
This book seems much better than the other Celko books I've read or browsed- not surprising since its his core, original book.

The good:
It covers a wide range of topics, including detailed examples of many interesting niche cases.

Celko doesn't seem to be as much of a jerk as in the other two books I've read (SQL Programming Style and Thinking In Sets).

I think this book gave decent coverage of everything in those other two books- I'm not sure they really need to exist at all. He does regularly call out when there is more coverage available in a specific book, and that may make sense in other cases.

The meh:
Lots of repetition (but if you want to use it as an occasional reference, that may be good).

Examples tend to switch between several different formats (sometimes the schema is illustrated with data, sometimes with CREATE statements, only occasionally is result data shown), and it doesn't seem to be a conscious choice.

Physical formatting could be a lot better- often a huge margin sits next to lines of code that wrap unnecessarily.

And he frequently uses the !@#$ing pre-ANSI-99 join criteria syntax, just like some of my !@#$ Oracle-centric co-workers.
Profile Image for Ji.
175 reviews51 followers
July 4, 2021
Because of its author, this book has some reputation out there. I read through part of it at the time when I started, and never finished it. The book gives some interesting thoughts about SQL. But the code examples are not too useful since there are a lot of errors..
144 reviews5 followers
February 15, 2023
This book is rightfully known as the book on SQL Programming - and rightfully so. Obviously the author is extremely knowledgable on the subject, and his time on the SQL Standards committee is obviously well reflected in this book. I have also read a few of his other books, notably Joe Celko's Trees and Hierarchies in SQL for Smarties, and I particularly like the balance of formal teaching, practical tips, and several examples.

However, that said, I had to take away a star in my review. When a topic that is covered in another book is reprinted in this one, it makes sense, and hopefully encourages readers to explore some of the other books in greater detail. But, especially towards the back quarter of the book, there were several sections reprinted in verbatim (the first example that comes to mind is the DATE TIME section (~ ch9) in the Temporal Queries section (Ch 35). I get that perhaps some people would view this book as a "cookbook" style text - but it would be much better if the author would have just pointed the reader to the prior section. Also, while I did not reduce my rating, towards the end of the book the editing seems to get a bit lax.

Stylistic complaints aside, this book is a gold mine of information, and I strongly recommend people who are interested in developing some SQL skills to check it out.
Profile Image for Maxim.
33 reviews1 follower
September 10, 2019
It's close to Mark Lutz's "Learning Python", which means that it's close to horrible.

Very inconsistent, with broken and didactic examples, overly abstract, bloated, etc.

I've plowed through it with difficulty a couple of years ago, and still have the feeling that I've wasted my time.

IMHO, it's better to read 2-3 smaller and practical books, then waste your time on this one.
Profile Image for Fred.
401 reviews11 followers
August 3, 2019
This book really opened my eyes to the value of DBMS software provided by Oracle. Trying to implement some Oracle functionality with pure ANSI SQL is painful but enlightening.
Profile Image for Tuomas Hietanen.
1 review3 followers
March 21, 2025
Good for general SQL, however a bit out-dated, some SQL execution engines have been improved since the book release. Also this focus more on standard SQL than e.g. T-SQL.
Profile Image for Robert Beveridge.
2,402 reviews197 followers
March 27, 2014
Joe Celko, SQL for Smarties 4/E (Morgan Kaufmann, 2011)

Full disclosure: a copy of this book was provided to me free of charge by Amazon Vine.

It had been a very long time since I had updated the Duration column on my spreadsheet, but I figured if any book warranted doing so, it would be SQL for Smarties. I knew it had taken me a long, long time to get through it (it sat on my desk at work for quite a while and I had no time there to get to it), but even I didn't know how long specifically. As of this writing, it is the third-longest I have ever taken to read a book—from first page to last, 1,062 days. (#2 is a book that had gone back to the library for three years before I took it out again; #1 is a book that got lost for four years before I stumbled upon it in a box and finished it up within the week.) That is one heckuva lot of time for a book, but then SQL for Smarties is not normally the kind of book one reads from beginning to end anyway, so take all that with a grain of salt.

The bad part: there are long stretches of it that are pretty dry. Celko has been a member of many of the SQL standards committees, and quotes at length from the documents he helped to author for them. For some people, that might be a great way to learn. Me, I'm a big fan of examples, and lots of them, and they do show up in almost every section; I would've liked a stronger focus on practice than theory, but well, YMMV, and probably will. This is balanced out by the fact that when Celko lets his (non-existent) hair down, every once in a while a sentence will pop out that you can't believe you just read in what is, essentially, a technical manual, and those sorts of little surprises may seem like throwaways, but for someone like me, they add a lot of intangible value; this one will be a ref manual on my shelf after a lot of other ones have fallen by the wayside.

The other drawback, and this was a consciously-planned one on Celko's part, is that the book is language-pure, which pretty much by definition in today's world means implementation-agnostic. Which is not a bad thing on the theory level, but can be nightmare in practice if you straddle a couple of database lines. I work with both T-SQL and MySQL, and more than once I've found myself doing something like saying “well, why aren't we using a LIMIT statement there?” when talking about a stored procedure in T-SQL. “See? Right here in Celko...”, and then we actually try it and Microsoft borks because LIMIT doesn't exist in T-SQL. (Hey, Microsoft, fix that, it's an amazing function.) To be fair to Celko, he throws in an admonition about that every so often, but that won't combat wishful thinking.

On the other hand, the big, big upside is that as long as you keep the above caveats in mind, SQL for Smarties is really the only SQL reference book you'll ever need (pending new editions, of course); it may not be exhaustive—I think I remember Celko saying that once or twice—but it's pretty comprehensive, it dives into nooks and crannies that most people will never explore (even if they should), it addresses not only the way the language should be used but the ways it shouldn't (and is often pressed into service to do anyway), etc. There is a massive wealth of information here for database developers who use a flavor of SQL, and it belongs on the shelf of every person who fits that description, amateur or professional. *** ½
Profile Image for Kevin.
291 reviews13 followers
June 4, 2010
Good, but a bit over-rated. Some of the code in here is a bit obscure and most would probably have trouble finding use for it on everyday projects. Still neat, though.
Profile Image for Steven.
Author 1 book63 followers
November 21, 2014
You will learn a lot by reading this book if you have a basic grounding in SQL and are looking to stretch yourself to solving the most difficult SQL problems in a set-oriented way.
Displaying 1 - 16 of 16 reviews

Can't find what you're looking for?

Get help and learn more about the design.