Binary Tree Nodes

  • + 0 comments

    * WHEN N NOT IN(SELECT DISTINCT(P) FROM BST) THEN "Leaf" ELSE * We want N NOT IN(SELECT DISTINCT(P) FROM BST) to return True for nodes which are not present in attribute P In SQL, NOT IN fails if the subquery returns even one NULL. The subquery return Null for Root node. When you do N NOT IN (...) and the list contains NULL, the result is unknown, so the whole WHEN condition is false, even for correct leaves. * ....WHEN N NOT IN(SELECT DISTINCT(P) FROM BST WHERE P IS NOT NULL) THEN "Leaf" ....* for desired result NOTE :- ...WHERE P IS NOT NULL... for avoiding error due to edge cases