I have the following query
DateADD(day,9-DATEPART(dw,cdata .call_datetime ),cast(cdata .call_datetime as date) ) as effective_date
, A.EmployeeID AS employee_id
, COUNT(cdata .Extension) AS metric_value
--, ISNULL(MS.metric_id,'') AS metric_id
[Enabled] = 'True'
INNER JOIN [vw_exampl] cdata ON A.EmployeeID =cdata .employeeID
INNNER JOIN tbl2 ON A.employyeid=tbl2.employeeid
, DateADD(day,9-DATEPART(dw,cdata .call_datetime ),cast(cdata .call_datetime as date) )
I can see that the view runs pretty slow and makes this query to run slow.It takes hours to complete and which I dont want it to happen, also the view has nearly 5 million rows of data in it.
Could someone recommend me how to make the query faster?
Any feedback or suggestions on the query?