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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.