608. 树节点
/* Write your T-SQL query statement below */ SELECT id , (CASE WHEN p_id IS NULL THEN 'Root' ELSE -- 根节点,p_id为null CASE WHEN id IN (SELECT p_id FROM tree) THEN 'Inner' ELSE 'Leaf' END -- 是否有孩子节点,若有,则内部节点,否则叶子节点 END ) AS type FROM tree ORDER BY id
有志者,事竟成,破釜沉舟,百二秦关终属楚; 苦心人,天不负,卧薪尝胆,三千越甲可吞吴。