✅ Simple solution using CASE WHEN ✅
\n\n# Approach\nJust Used CASE WHEN for this Problem.\n\nFirst Condition Ensured parent_id is NULL for the particular_id, if NULL then it simply \'Root\'.\n\nSe
\n\n# Approach\nJust Used CASE WHEN for this Problem.\n\nFirst Condition Ensured parent_id is NULL for the particular_id, if NULL then it simply \'Root\'.\n\nSecond Condition particular_id NOT IN the parent_id, if it is not then obviously they are not Parents, If they are not Parents then there is no passible way they have Child hence automaically they are \n\'Leaf\'.\n\nFinal condition, none other than these two will become \'Inner\'\n\n\n# Code\n```postgresql []\n-- Write your PostgreSQL query statement below\nSELECT id, \n  CASE WHEN p_id IS NULL THEN \'Root\' \n  WHEN id NOT IN (SELECT p_id FROM Tree WHERE p_id IS NOT NULL) THEN \'Leaf\'\n  ELSE \'Inner\' END as type \nFROM Tree\n\n\n```
['PostgreSQL']