테이블 구조
Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node
SELECT n
,CASE WHEN p IS NULL THEN 'Root'
WHEN n NOT IN (SELECT DISTINCT p FROM bst WHERE p is NOT NULL) THEN 'Leaf'
ELSE 'Inner' END AS tree
FROM bst
ORDER BY n
;
Null 이 포함되면 숫자형으로 반환되지 않으므로,
case when 두번째 문에서 'IS NOT NULL' 추가.