Skip to Content
Learn SQL in a Month of Lunches
book

Learn SQL in a Month of Lunches

by Jeff Iannucci
February 2025
Beginner content levelBeginner
304 pages
8h 8m
English
Manning Publications
Content preview from Learn SQL in a Month of Lunches

21 Making decisions in queries

Now that you know how to add, update, or remove data from a table, let’s look at some of the tools SQL provides for making decisions in queries and stored procedures. What if you want to group data and return a value of 0 if a value of the SUM is NULL, for example? What if you want to make the output of a query dependent on some condition or to evaluate parameters in a stored procedure and provide conditional feedback in the output? This chapter looks at all these scenarios and more.

21.1 Conditional functions and expressions

Do you recall that you’ve already used one function in a conditional expression a few times? That function is COALESCE. You used it in chapter 15 to concatenate the full names of authors and ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition

SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition

John L. Viescas
SQL Cookbook, 2nd Edition

SQL Cookbook, 2nd Edition

Anthony Molinaro, Robert de Graaf

Publisher Resources

ISBN: 9781633438576Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link