SELECT name,
CASE WHEN boss = '' -- or maybe WHEN boss IS NULL
THEN 'CEO'
WHEN EXISTS (SELECT NULL FROM employment t2 WHERE t1.name = t2.boss)
THEN 'MANAGER'
ELSE 'WORKER'
END posession
FROM employment t1
select Name,
case
when BOSS = "" then "CEO"
when exists(select NULL from employment t2 where t1.NAME = t2.BOSS) then "MANAGER"
else "WORKER"
end as BOSS
from Employment t1
2
Answers
So, this can be solved using the case expression.