Issue
Is it possible to make a query that returns a different custom value based on a query? Here is an example:
What I have in the table ...
| number |
|---|
| 1 |
| 2 |
| 3 |
... and this is what I want returned:
| number |
|---|
| one |
| two |
| three |
How can this be done?
Solution
You want a case statement. Depending on your flavor of SQL, something like this should work:
select
bar = case
when foo = 1 then 'one'
when foo = 2 then 'two'
else 'baz'
end
from myTable
Answered By - Chase Answer Checked By - Pedro (sql.easybugfix Volunteer)
Post a Comment
Post a Comment