Skip to content

Instantly share code, notes, and snippets.

@indigo423
Last active May 7, 2018 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indigo423/49301465e65367b2ac38b9b8fc21871c to your computer and use it in GitHub Desktop.
Save indigo423/49301465e65367b2ac38b9b8fc21871c to your computer and use it in GitHub Desktop.
OpenNMS View for nodes with categories
CREATE VIEW node_categories AS (
SELECT
n.*,
COALESCE(s_cat.categoryname, 'no category') AS categoryname
FROM
node n
LEFT JOIN
category_node cn
ON
n.nodeid = cn.nodeid
LEFT JOIN
categories s_cat
ON
cn.categoryid = s_cat.categoryid
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment