Skip to content

Instantly share code, notes, and snippets.

@jwliechty
Created September 15, 2014 19:15
Show Gist options
  • Save jwliechty/92ed4f55973e676b169c to your computer and use it in GitHub Desktop.
Save jwliechty/92ed4f55973e676b169c to your computer and use it in GitHub Desktop.
Find id's of a dimension referenced from a fact table via multiple attributes.
SELECT dim.id FROM dim WHERE dim.id NOT IN
(
SELECT DISTINCT fact.dim_one_id FROM fact
)
AND dim.id NOT IN
(
SELECT DISTINCT fact.dim_two_id FROM fact
)
AND dim.id NOT IN
(
SELECT DISTINCT fact.dim_three_id FROM fact
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment