Mysql join two tables with counpe oft the different type of records -
i'm having 2 table sendmail , campaign tables in mysql. sendmail table represents both sent , failed status in stats field. , campaign filed having campaign table id reference. i'm trying display how many mails had been sent , failed in each campaign. 2 table structure are, sendmail table
campaign table structure , expected result:
campaigname totalsent totalunsend aaaa 0 1 supply chain 6 0 development 6 0 design&development 8 3
you can use query this:
select campaign.name, sum(status=1) totalsent, sum(status=0) totalunsent campaign inner join sendmail on campaign.campaignid = sendmail.campaignid group campaign.name
Comments
Post a Comment