Reputation: 7
I have information that I am trying to report on that is currently categorized via a vlookup table in excel. This table would check the data coming from my days_past_due
column in SQL database and return a string.
I.E. days_past_due = 5
would return the string '5-10 Days Past due'
I have about 8 different number ranges that would get their own string. Is their a way to hardcode this into the SQL query?
It is worth mentioning the string data is NOT in my database.
Upvotes: 0
Views: 171
Reputation: 1221
Use the CASE function to achieve this.
SELECT CASE
WHEN days_past_due = 5 THEN '5-10 Days Past due'
WHEN ......
ELSE <returndefaultcase>
END
FROM <tablename>
Upvotes: 2
Reputation: 12969
you can use CASE logic to get this.
SELECT CASE WHEN days_past_due = 5 THEN '5-10 Days Past due'
WHEN ...
END
FROM YourTableName
Upvotes: 0