my sql hard but same in postgreSQL was faster
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\n# Write your MySQL query statement below\nselect id, case\nwhen p_id is null then \'Root\'\nwhen id in (select distinct p_id from tree) then \'Inner\'\nelse \'Leaf\' end as type\nfrom tree\norder by id\n```
['MySQL']