I'm trying to replicate the equivalent of:
select name, salary, decode(salary > 100, "Nice Job", job) as job
from blah...
blah table being:
name
salary
job
Is there an equivalent of decode or if or switch or something?
try:
select name, salary, case when salary > 100 then "Nice Job" else job end as job
from blah...
If job
is an integer, you need to convert it to a string:
select (case when salary > 100 then "Nice Job" else cast(job as varchar(255))
end) as job
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.