You are viewing a single comment's thread. Return to all comments →
This solution may be more performant for very large tables as it doesn't require the creation of a whole new DISTINCT set
SELECT N, CASE WHEN P IS NULL THEN 'Root' WHEN EXISTS (SELECT 1 FROM BST AS B2 WHERE B2.P = B1.N) THEN 'Inner' ELSE 'Leaf' END FROM BST AS B1 ORDER BY N
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Tree Nodes
You are viewing a single comment's thread. Return to all comments →
This solution may be more performant for very large tables as it doesn't require the creation of a whole new DISTINCT set