tanj1035
asked on
SQL, how to sum up the column when the value >=5
Hi Experts, I want the expected result to sum up values when "days before test drive" >=5. How can I modify my query? Thanks.
select count (dealID) as RequestedTestDrive,daysbeforetestdrive
from
(select distinct d.dealid, datediff(day, max(cast(t.createdon as date)), max(cast (t.appointmentlocaltime as date))) as daysbeforetestdrive
from [MakeMyDeal_com].[dbo].[TestDrivelocal] t
inner join Mmd_feed..dealview d on t.dealid=d.dealid
inner join Mmd_feed..dart dt on dt.dealerid=d.dealerid
where cast(t.createdon as date)>=@StartDate and cast(t.createdon as date)<=@EndDate
and d.dealstatus='sent'
and d.alternatedeal ='no'
and d.manualdeal='no'
group by d.dealid)as t
group by daysbeforetestdrive
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER