solution using left outer join.
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/* Write your PL/SQL query statement below */\nselect Distinct id,type from(\nselect T.id,\ncase\nwhen T.p_id is null then \'Root\'\nwhen T1.p_id is null then \'Leaf\'\nELSE \'Inner\'\nend as type\nfrom Tree T left outer join Tree T1\non T.id=T1.p_id\n)\n```
['Oracle']