Efficient way to check for number of records more than a limit from a table in SQL Server
CREATE NONCLUSTERED INDEX IX_StagingStatusId ON Accounts(StagingStatusId)INCLUDE(IsActive, IsApproved);

SELECT T.StagingStatusId
     ,'StatCounts'= CASE WHEN T.Total&gt;999 THEN '&gt;999'
                         WHEN T.Total&lt;999 THEN '&lt;999'
                       END 

 FROM (
select StagingStatusId, count(*) AS Total
from Accounts
where IsActive = 1 and IsApproved = 1
group by StagingStatusId
) AS T