✅ [Accepted] Solution for MySQL
sql\nSELECT id,\n     CASE \n     WHEN p_id IS NULL THEN "Root"\n     WHEN id IN (SELECT p_id FROM tree) THEN "Inner"\n     ELSE "Leaf" END AS Type\nFROM tree O
```sql\nSELECT id,\n     CASE \n     WHEN p_id IS NULL THEN "Root"\n     WHEN id IN (SELECT p_id FROM tree) THEN "Inner"\n     ELSE "Leaf" END AS Type\nFROM tree ORDER BY id\n```
['MySQL']