โข
ํ๋ฆผ
SELECT
DISTINCT BST.N,
CASE
WHEN BST.P IS NULL THEN 'Root'
WHEN B2.N IS NULL THEN 'Leaf'
ELSE 'Inner'
END
FROM BST
LEFT JOIN BST B2 ON BST.N = B2.P
ORDER BY BST.N
;
JavaScript
๋ณต์ฌ
์ด์ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์