AC Solution
\nselect T.id, \nIF(isnull(T.p_id), 'Root', IF(T.id in (select p_id from tree), 'Inner', 'Leaf')) Type \nfrom tree T\n
```\nselect T.id, \nIF(isnull(T.p_id), 'Root', IF(T.id in (select p_id from tree), 'Inner', 'Leaf')) Type \nfrom tree T\n```
[]