Using CASE
\nselect id,\n    case when p_id is null then \'Root\'\n         when id in (select p_id from tree) then \'Inner\'\n         else \'Leaf\'\n    end as type\nfro
```\nselect id,\n    case when p_id is null then \'Root\'\n         when id in (select p_id from tree) then \'Inner\'\n         else \'Leaf\'\n    end as type\nfrom Tree\norder by id\n```
[]