[문제]
[MySQL]
WITH node AS (
SELECT t1.*
, t2.id AS c_id
FROM Tree AS t1
LEFT JOIN Tree AS t2 ON t1.id = t2.p_id
)
SELECT DISTINCT id
, CASE WHEN p_id IS NULL THEN 'Root'
WHEN c_id IS NULL THEN 'Leaf'
ELSE 'Inner'
END AS type
FROM node
'SQL > LeetCode' 카테고리의 다른 글
| [LeetCode] 619. Biggest Single Number (0) | 2025.02.18 |
|---|---|
| [LeetCode] 610. Triangle Judgement (0) | 2025.02.18 |
| [LeetCode] 607. Sales Person (0) | 2025.02.18 |
| [LeetCode] 602. Friend Requests II: Who Has the Most Friends (0) | 2025.02.18 |
| [LeetCode] 601. Human Traffic of Stadium (0) | 2025.02.18 |
