Last active
September 12, 2016 12:57
-
-
Save jaymay/89567916c877a264b7d6ff566b7f1a10 to your computer and use it in GitHub Desktop.
Medidata request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
e.author_id, | |
u.name, | |
ui.value as email, | |
u.roles, | |
count(distinct e.parent_id) num_distinct_updates_wo_reassigment | |
from classic.events e | |
inner join users u on e.author_id = u.id | |
inner join user_identities ui on e.author_id = ui.user_id | |
where e.account_id = 361618 | |
and e.delta_date between 20160601 and 20160601 -- set date range | |
and ui.type like '%Email%' -- pull only email identities | |
and ui.priority = 1 -- only look at the primary email address | |
and u.roles > 0 -- only look at user's with an agent/admin role | |
and e.author_id != -1 -- remove system updates | |
and e.parent_id is not null -- remove parent events | |
and e.type in ('Comment','Create','Change') -- only look at events that are comments, creates, or updates | |
and e.value_reference != "group_id" -- remove all group changes | |
and e.value_reference != "assignee_id" -- remove all assignee changes | |
group by | |
e.author_id, | |
u.name, | |
ui.value, | |
u.roles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment