Skip to content

Instantly share code, notes, and snippets.

@prmoore77
Last active June 7, 2022 20:04
Show Gist options
  • Save prmoore77/71bee9be36bd848ef15bb046ff565e60 to your computer and use it in GitHub Desktop.
Save prmoore77/71bee9be36bd848ef15bb046ff565e60 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE TEMPORARY TABLE product_nodes_temp
AS
SELECT node_id
, node_natural_key
, node_name
, level_name
, parent_node_id
, CASE WHEN parent_node_id IS NULL
THEN TRUE
ELSE FALSE
END AS is_root
, CASE WHEN node_id IN (SELECT parent_node_id
FROM product_nodes
)
THEN FALSE
ELSE TRUE
END AS is_leaf
FROM product_nodes
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment