Skip to content

Instantly share code, notes, and snippets.

@trullock
Forked from gshutler/gist:4030506
Created November 7, 2012 09:59
Show Gist options
  • Save trullock/4030551 to your computer and use it in GitHub Desktop.
Save trullock/4030551 to your computer and use it in GitHub Desktop.
set transaction isolation level read uncommitted
select
c.[Id],
c.[Name],
c.[SentOn],
count(s.Id) as sent,
sum(cast(s.[Bounced] as int)) as bounced,
sum(cast(s.[Complained] as int)) as complained,
sum(cast(s.[Opened] as int)) as opened,
(select count(1) from [Email_Sent] s inner join [Email_Clicked] ec on ec.[EmailId] = s.[Id] where c.Id = s.CampaignId) as clicks
from [EmailCampaign] c
left join [Email_Sent] s on c.Id = s.CampaignId
group by
c.[Id],
c.[Name],
c.[SentOn]
order by
[SentOn] desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment