How to Format a SQL CASE Statement
By Sharon Ben-Moshe · Jun 15, 2026
SQL CASE statements get messy fast. Here's how to format simple, multi-branch, and nested CASE WHEN expressions to stay readable as logic grows.
Read postsqlfmt▍
sqlfmt blog
Practical posts on writing cleaner SQL and fixing the errors your database gives back.
By Sharon Ben-Moshe · Jun 15, 2026
SQL CASE statements get messy fast. Here's how to format simple, multi-branch, and nested CASE WHEN expressions to stay readable as logic grows.
Read postBy Sharon Ben-Moshe · Jun 15, 2026
BigQuery syntax errors point past the real mistake. Here are 7 common causes—wrong clause order, reserved words, Legacy SQL—with runnable fixes.
Read postBy Sharon Ben-Moshe · Jun 14, 2026
Eight SQL formatting best practices — keyword casing, comma style, explicit JOINs, CTE usage, and keyword typo checking — with before-and-after examples.
Read postBy Sharon Ben-Moshe · Jun 14, 2026
SELEC, FORM, WHER — SQL keyword typos produce confusing parser errors. Here are the most common SQL misspellings and the fastest ways to catch them.
Read postBy Sharon Ben-Moshe · Jun 14, 2026
Leading comma style in SQL places commas before each column, not after. Here's the case for and against it, and how to enforce it consistently.
Read postBy Sharon Ben-Moshe · Jun 14, 2026
SQL Server's "Incorrect syntax near" error means the T-SQL parser hit an unexpected token. Here are 7 common causes and how to fix each one.
Read postBy Sharon Ben-Moshe · Jun 14, 2026
Should SQL keywords be uppercase or lowercase? We compare major style guides, tool defaults, and team conventions to give you a clear, defensible answer.
Read postBy Sharon Ben-Moshe · Jun 14, 2026
SQLite's 'near X: syntax error' points just past the real mistake. Here are 7 common causes—reserved words, quote confusion, version gaps—with fixes.
Read postBy Sharon Ben-Moshe · Jun 14, 2026
SQL's = NULL comparison always returns unknown, never true. Learn why NULL requires IS NULL, how three-valued logic works, and how to fix common NULL bugs.
Read postBy Sharon Ben-Moshe · Jun 13, 2026
"You have an error in your SQL syntax" (MySQL error 1064) means the parser hit an unexpected token. Here are the 7 common causes and how to fix each.
Read post