Leetcode - 608. Tree Node
문제
정답
SELECT id,
CASE
WHEN ISNULL(p_id) THEN 'Root'
WHEN id IN (SELECT p_id FROM Tree) THEN 'Inner'
ELSE 'Leaf'
END as type
FROM Tree
SELECT id,
CASE
WHEN ISNULL(p_id) THEN 'Root'
WHEN id IN (SELECT p_id FROM Tree) THEN 'Inner'
ELSE 'Leaf'
END as type
FROM Tree