Easy SQL Query
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 MySQL query statement below\nSELECT id,\'Root\' AS type\nFROM Tree\nWHERE p_id is NULL\nUNION\nSELECT T1.p_id,\'Inner\' AS type FROM Tree AS T1\nCROSS JOIN \nTree AS T2\nWHERE T1.p_id=T2.id AND T1.id is NOT NULL AND T2.p_id is NOT NULL\nUNION\nSELECT T1.id,\'Leaf\' AS type FROM Tree AS T1\nLEFT JOIN \nTree AS T2\nON T1.id=T2.p_id\nWHERE T2.id is NULL AND T1.p_id is NOT NULL;\n```
['MySQL']