I have a table called "employment" which looks like
if the boss column is empty it means he/she is the "CEO"
and if he/she manages one another under boss column it means "Manager"
else it’s "Worker"
Finally it should look like
Can you help build some query to make the following result?
Thank you
>Solution :
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

