using case when statements
\nselect \n    id,  \n    case when p_id is null then \'Root\' \n    when id in (select p_id from tree) then \'Inner\' \n    else \'Leaf\' end as type\nfrom\n  
```\nselect \n    id,  \n    case when p_id is null then \'Root\' \n    when id in (select p_id from tree) then \'Inner\' \n    else \'Leaf\' end as type\nfrom\n    tree \n    \n```\n\nif u like this solution, please upvoate so i can push myself even more ! Thanks :D \n
[]