Created
November 7, 2012 09:39
-
-
Save trullock/4030415 to your computer and use it in GitHub Desktop.
This file contains 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
set transaction isolation level read uncommitted | |
select | |
c.[Id], | |
c.[Name], | |
c.[SentOn], | |
count(distinct s.Id) as sent, | |
sum(case when s.[Bounced] = 1 then 1 else 0 end) as bounced, | |
sum(case when s.[Complained] = 1 then 1 else 0 end) as complained, | |
sum(case when s.[Opened] = 1 then 1 else 0 end) as opened, | |
count(ec.[Id]) as clicks | |
from [EmailCampaign] c | |
left join [Email_Sent] s on c.Id = s.CampaignId | |
left join [Email_Clicked] ec on ec.[EmailId] = s.[Id] | |
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