Sql Query Performance I have one query for the report.

Query 

Use RIS

select CİHAZ,sum(sayi) as [Çekim Sayısı], count(*) as [Hasta Sayısı] from
(select CİHAZ,[KABUL NO],[TC NO], count(*) as Sayi from 

(SELECT 
a.GeneralReceptionNo as [KABUL NO], pa.TRIDNO as [TC NO],
m.EtiketAdi as [CİHAZ]
FROM   Appointments a 
INNER JOIN Examinations e    ON a.ObjectID=e.AppointmentID   --aobject 1392334
INNER JOIN Patients pa       ON a.PatientID=pa.ObjectID
INNER JOIN Procedures pr     ON a.ProcedureID=pr.ObjectID
LEFT OUTER JOIN Machines m   ON a.MachineID=m.ObjectID
LEFT OUTER JOIN ExaminationReportAssistanceAssociation ra ON e.ObjectID =ra.ExaminationID  
INNER JOIN Hospital..Receptions r       ON r.GeneralReceptionNo =a.GeneralReceptionNo 
WHERE 
CONVERT (DATE,e.CompletedDate)&gt;='2018-12-01'
AND CONVERT (DATE,e.CompletedDate)&lt;'2019-12-30' AND e.IsCompleted =1) sorgu
GROUP BY CİHAZ,[KABUL NO],[TC NO] ) sorgu2
GROUP BY CİHAZ ORDER BY CİHAZ


My problem is ,when i wrote condition is CONVERT (DATE,e.CompletedDate)&gt;='2018-12-01'
AND CONVERT (DATE,e.CompletedDate)&lt;'2019-11-30' , query not ended in 50 min but

if i wrote condition is CONVERT (DATE,e.CompletedDate)&gt;='2018-11-01'
AND CONVERT (DATE,e.CompletedDate)&lt;'2019-11-30'
 I can get the result in 12 sec.

First example time range wider than the second example. I can't find a solution. Thanks for the help.
Why are you using the condition?

CONVERT (DATE,e.CompletedDate) &gt;= '2018-11-01' 
AND CONVERT (DATE,e.CompletedDate) &lt; '2018-11-30'


This query is not SARGable, just rewrite your query as

e.CompletedDate &gt;= '2018-11-01' 
AND e.CompletedDate &lt; '2018-11-30'


And ensure you have an index with CompletedData field as the first field. As far as I see the condition, it should work in the same way but much faster and will use minimal resources.

As per your comment, apart from the proposed change in your WHERE condition you need to create a new index as:

CREATE INDEX IX_Examinations_CompletedDate ON Examinations(CompletedDate)