Beginner's SQL: CASE expressions
There's more to SQL than SELECT columns FROM tables, just as there's more to life than Go, Dog. Go!SQL can, to someone learning it, seem incredibly difficult beyond the simplest statements. There's nothing wrong with simple SQL, though. Part of the art of SQL is getting complex results with simple statements. And as parents who have read this book many times can confirm, even Go, Dog. Go! is filled with subtlety, intrigue, beauty, power, wonder, infuriation, surprise, and joy, all while being written in simple language. Just like SQL.
This article describes CASE expressions and what you can do with them. The syntax is covered briefly, mainly because there's little to explain, since it's rather straightforward. At least, so it appears on the surface. Then come the examples, which reveal how comprehensive, powerful, yet simple your SQL can be with CASE expressions.
Read More