MS-SQL-Server Solution
Solution:\n\n```\nSelect\n    id\n,   case \n        when p_id is null then \'Root\'\n        when exists (Select p_id From Tree tr Where t.id=tr.p_ID) then \'I
Solution:\n\n```\nSelect\n    id\n,   case \n        when p_id is null then \'Root\'\n        when exists (Select p_id From Tree tr Where t.id=tr.p_ID) then \'Inner\' else \'Leaf\'\n    end \'type\'\nFrom Tree t\nOrder By t.id asc;\n\n\n\n
['MySQL', 'MS SQL Server']