DEV Community

[Comment from a deleted post]
Collapse
 
sqlknowitall profile image
Jared Karney • Edited

Great article and example! Since you didn't mention when to use this, or more importantly when NOT to use it, I wanted to caution users that just found something they can use EVERYWHERE. Take the above example. If it simply did what SQL is great at doing, return the stored values, it could be used for several different reports. What if u wanted to change those boundaries or labels. As a 'general' rule, I don't use CASE unless it literally changes rows or columns that may be returned in the end result. Remember that SQL isn't a presentation layer formatter, it's to retrieve data for someone to format the way they want.