You may know SQL basics, but are you taking advantage of its expressive power? This second edition applies a highly practical approach to Structured Query Language (SQL) so you can create and manipulate large stores of data. Based on real-world examples, this updated cookbook provides a framework to help you construct solutions and executable examples in several flavors of SQL, including Oracle, DB2, SQL Server, MySQL, and PostgreSQL.
SQL programmers, analysts, data scientists, database administrators, and even relatively casual SQL users will find SQL Cookbook to be a valuable problem-solving guide for everyday issues. No other resource offers recipes in this unique format to help you tackle nagging day-to-day conundrums with SQL.
The second edition includes:
Fully revised recipes that recognize the greater adoption of window functions in SQL implementations Additional recipes that reflect the widespread adoption of common table expressions (CTEs) for more readable, easier-to-implement solutions New recipes to make SQL more useful for people who aren’t database experts, including data scientists Expanded solutions for working with numbers and strings Up-to-date SQL recipes throughout the book to guide you through the basics
From the brand

Explore our collection
More From O’Reilly

Sharing the knowledge of experts
O’Reilly’s mission is to change the world by sharing the knowledge of innovators. For over 40 years, we’ve inspired companies and individuals to do new things (and do them better) by providing the skills and understanding that are necessary for success.
Our customers are hungry to build the innovations that propel the world forward. And we help them do just that.
Publisher : O’Reilly Media
Publication date : December 8, 2020
Edition : 2nd
Language : English
Print length : 567 pages
ISBN-10 : 1492077445
ISBN-13 : 978-1492077442
Item Weight : 2.05 pounds
Dimensions : 7 x 1.25 x 9 inches
Best Sellers Rank: #747,216 in Books (See Top 100 in Books) #27 in MySQL Guides #76 in SQL #93 in Data Warehousing (Books)
Customer Reviews: 4.6 4.6 out of 5 stars (232) var dpAcrHasRegisteredArcLinkClickAction; P.when(‘A’, ‘ready’).execute(function(A) { if (dpAcrHasRegisteredArcLinkClickAction !== true) { dpAcrHasRegisteredArcLinkClickAction = true; A.declarative( ‘acrLink-click-metrics’, ‘click’, { “allowLinkDefault”: true }, function (event) { if (window.ue) { ue.count(“acrLinkClickCount”, (ue.count(“acrLinkClickCount”) || 0) + 1); } } ); } }); P.when(‘A’, ‘cf’).execute(function(A) { A.declarative(‘acrStarsLink-click-metrics’, ‘click’, { “allowLinkDefault” : true }, function(event){ if(window.ue) { ue.count(“acrStarsLinkWithPopoverClickCount”, (ue.count(“acrStarsLinkWithPopoverClickCount”) || 0) + 1); } }); });


The Marshal –
Great Resource
A MUST HAVE for those using SQL and looking for IBM DB2 examples.
nazar –
Great book
Great book
Arturo Paz –
My first SQL Book
I’m really looking forward to diving into this book. I bought it to improve my understanding of SQL. This book covers a wide range of topics. I love it.
andes corchuelo –
Sql
Es un repaso muy bueno, en el cual te ayuda a recordar tips que haveces se pasan por alto
Critic –
Excellent reference for all experience levels
The book is well organized with clear, practical examples.
Gennish100 –
Quality of paper good and great examples without being bloated
Good
Rodney B –
Cooking with SQL: Where Simple NULL Sorting Turns Into Another Book
—## 📘 *SQL Cookbook* by Anthony Molinaro — *In-Progress Review*I’m currently working through Chapter 3, and I’ve developed a full-blown **love-hate relationship** with this book. So consider this an *in-progress review*—I’ll revise it once I’ve finished the full read.Molinaro’s *SQL Cookbook* is undeniably thoughtful. It tackles real-world SQL challenges across multiple platforms and shines when showcasing dynamic query logic—especially with clever uses of `CASE` expressions to adapt sorting behavior. These moments feel sharp, practical, and well-earned.But then the momentum stalls.Some sections over-explain basic concepts—like sorting NULLs or handling nullable columns—turning what should be a footnote into a five-page saga. Meanwhile, more creative techniques, like using `REPLACE` and `TRANSLATE` in the `ORDER BY` clause, are barely unpacked. For example, this query sprawls across four databases and 2 pages, but the explanation is minimal and rest are code and outputs“`sqlSELECT dataFROM vwORDER BY REPLACE(data,REPLACE(TRANSLATE(data, ‘0123456789’, ‘##########’),’#’,”),”);“`It’s clever, but under-explained. I found myself reverse-engineering the logic just to understand the intent—something the book should’ve guided more clearly.There’s also a sense that the author is trying to cover *everything*, which leads to scattered focus. At times, it feels like he’s padding the book rather than deepening the insight. The reliance on just a few major tables—mostly `emp` and `dept`—limits the variety and richness of the result sets. For example:“`sqlCREATE VIEW ve ASSELECT e.ename, e.job, e.salFROM emp eWHERE e.job = ‘CLERK’;SELECT e.empno, e.ename, e.job, e.sal, e.deptnoFROM emp eWHERE (e.ename, e.job, e.sal) IN (SELECT e.ename, e.job, e.salFROM emp eINTERSECTSELECT v.ename, v.job, v.salFROM ve v);“`This ultimately circles back to:“`sqlSELECT e.empno, e.ename, e.job, e.sal, e.deptnoFROM emp eWHERE e.job = ‘CLERK’;“`It’s a roundabout way to demonstrate set logic, but the payoff feels thin. I wish Molinaro had used more diverse sample databases or introduced richer table structures to make the examples more fruitful and engaging.That said, some of these patterns may come in handy later—especially if you’re working across DBMSs and need compatibility tricks. I’ll keep reading, annotating, and revising. Stay tuned for the full review… and possibly a companion book titled *“SQL Cookbook: The Annotated Remix.”*—
Pedro Ávila Núñez –
Libro SQL
Excelente libro para aprender más SQL Transact
Cliente de Amazon –
El libro está muy bien elaborado si ya estás familiarizado con SQL. Encontrarás todo tipo de ejemplos y ejercicios en cualquier SMDBD
Mara Jade –
In kleinen Abschnitten werden bestimmte Probleme/Themen angesprochen und leicht verständliche Lösungsansätze gezeigt.
Prem Kumar Sagar –
Delivered on time, well-packed, and the product matches the description perfectly. Quite happy with the purchase