sql server - SQL Get results back from every items in IN() -


hi can 1 me this?

i have made query:

select  distinct(campaign),      count(status)     c18_101 inner join client_10 on c18_101.id = client_10.id campaign in ('batch 1','batch 2','batch 3','batch 4','batch 5') , status = 'pending'  group  campaign,status 

the result looks this:

batch 2     241  batch 3     321  batch 4     575  batch 5     429 

i need result batch1 when there none.

select      x.campaign,      count(status)     (select distinct campaign c18_101) x     left join     client_10 c on x.id = c.id , c.status = 'pending'  group     x.campaign 
  1. you either group or aggregate, not both
  2. you distinct before join ensure counts correct per campaign
  3. do need campaign filter? if so, add derived table x

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -