title: How to reduce the query execution time
body: <p><a href="https://i.stack.imgur.com/dDwyR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dDwyR.png" alt="this is the execution plan"></a><a href="https://i.stack.imgur.com/u3nVw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u3nVw.png" alt="The image shows the results for the query and its taking 25secs for ~7500 rows"></a></p>
  
  <pre><code> SELECT dt AS Date
  ,monthname
  ,dayname
  ,(
      SELECT COUNT(1)
      FROM Calendar
      WHERE DATEPART(MM, dt) = DATEPART(MM, c.dt)
          AND DATEPART(YEAR, dt) = DATEPART(YEAR, c.dt)
      ) AS daysInMonth
  FROM Calendar AS c
  WHERE dt BETWEEN '2000-01-01 00:00:00'
      AND '2020-02-01 00:00:00'
  </code></pre>
  
  <p>the above query is for getting number of days of particular month for a particular date. here iam giving date range and for all the dates between the range iam just showing the days of that month.</p>
  
  <p>The image shows the results for the query and its taking 25secs for ~7500 rows. can someone help me to reduce the time.</p>