NOT IN didn't work due to null
Previously I had\n\nSELECT id,\n    CASE\n        WHEN p_id IS null THEN \'Root\'\n        WHEN id NOT IN (SELECT p_id FROM tree) THEN \'Leaf\'\n        ELSE \'
Previously I had\n```\nSELECT id,\n    CASE\n        WHEN p_id IS null THEN \'Root\'\n        WHEN id NOT IN (SELECT p_id FROM tree) THEN \'Leaf\'\n        ELSE \'Inner\'\n    END AS Type\nFROM tree\n```\nError.\nBecause for example\n```\n3 NOT IN (null, 1, 2)\n```\nreturns null and hence not identified as \'Leaf\'.\n\nTake out null and it works fine:\n```\nSELECT id,\n    CASE\n        WHEN p_id IS null THEN \'Root\'\n        WHEN id NOT IN (SELECT p_id FROM tree WHERE p_id IS NOT null) THEN \'Leaf\'\n        ELSE \'Inner\'\n    END AS Type\nFROM tree\n```
[]