Skip to content

Instantly share code, notes, and snippets.

@dklawren
Created November 16, 2016 17:59
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 dklawren/0895569a204b4e91f900441f0d83ca48 to your computer and use it in GitHub Desktop.
Save dklawren/0895569a204b4e91f900441f0d83ca48 to your computer and use it in GitHub Desktop.
SELECT DISTINCT
setter.login_name, ft.name, flag.status, grant_group.name
FROM
flags AS flag
JOIN
profiles AS setter ON flag.setter_id = setter.userid
JOIN
flagtypes AS ft ON ft.id = flag.type_id
JOIN
groups AS grant_group ON grant_group.id = ft.grant_group_id
LEFT JOIN
user_group_map AS ugm ON setter.user_id = ugm.user_id
WHERE
YEAR(flag.modification_date) = 2016
AND MONTH(flag.modification_date) > 2
AND ft.grant_group_id IS NOT NULL
AND ugm.group_id != gt.grant_group_id
AND (flag.status = '+' || flag.status = '-')
ORDER BY setter.login_name
LIMIT 100000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment