Advertisement
Wolfrost

SQL Labels Query

Jul 12th, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH common_releases AS (
  2.    SELECT release
  3.    FROM public.release_label
  4.    GROUP BY release
  5.    HAVING count(*) > 1
  6. ), common_releases_labels AS (
  7.    SELECT label
  8.    FROM public.release_label
  9.    INNER JOIN common_releases
  10.    ON public.release_label.release = common_releases.release
  11. )
  12. SELECT DISTINCT id, name
  13. FROM public.label
  14. INNER JOIN common_releases_labels
  15. ON public.label.id = common_releases_labels.label
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement