/* 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
标签:CASE,WHEN,608,节点,id,SELECT From: https://www.cnblogs.com/luyj00436/p/17096541.html