Each node in the tree can be one of three types:
Write a solution to report the type of each node in the tree.
Return the result table in any order.
The result format is in the following example.
SELECT id,
CASE
WHEN p_id IS NULL THEN 'Root'
WHEN id IN (SELECT DISTINCT(p_id) FROM Tree) THEN 'Inner'
ELSE 'Leaf'
END AS type
FROM Tree