I want add the condition "where alternativedeal " to the column "count(*) only", not to apply to the column "alternatedeals" and "createdeals".
Can you help me to correct it? Than kyou
with cte as (select [u](count(*) where alternativedeal is null) as dealstarts[/u],
sum(case when AlternativeDeal='1'then 1 else 0 end)as AlternateDeals,
sum(case when Manualsend='1'then 1 else 0 end) as CreatedDeals
and cast(submittedtimestamp as date) between '2015-05-01' and '2015-05-27'
and dealerid in (select dealerid from MMD_Feed..Dart)
group by dealerid)
select sum(ad.[WidgetInteraction]) as pencils,
from makemydeal_com.[dbo].[adobe_Standard] ad
inner join cte cte on cte.dealerid=ad.dealerid
inner join MMD_Feed..Deal d on d. dealerid=ad.dealerid
and cast(date as date) between '2015-05-01' and '2015-05-27'