This may be a silly question, but I’m trying to essentially take a value that’s in a field and IF contains “Tele” THEN result Televideo. Or it might be better: IF other than “Office” THEN result “Televideo”. <–This might be easier. I know it has to be apart of my select statement, I just didn’t know if I could call it out and then get the result to be different than the actual value there.
Other than select location_value from appt_data where appointment_date = ‘2020-12-04’…can I accomplish the above? I feel like I’d need a CASE statement and probably a =! operator. Any help is appreciated.
Advertisement
Answer
You want a case
expression:
x
select t.*,
(case when location_value like 'Tele%' then 'televideo'
else 'Office'
end) as location_grouping
from t;
Or perhaps:
select t.*,
(case when location_value = 'Office' then 'Office'
else 'televideo'
end) as location_grouping
from t;