Could anyone please help me optimize this suedo query? The source table contains about 10 million records. This query takes about two minutes to return. I have tried adding indexes, using subquries and also a CTE. Any help would be appreciated!
select aDate, aName, aInvoice,
'aCount' = CASE WHEN aType = 'AA' and aName in ('B','C','D','E','F') Then '1'
aType = 'AA'
and AName in ('B','C','D','E','F')
and aDate >= convert(VARCHAR(10), '02/01/2013', 101) and aDate < DATEADD(dd,1,convert(VARCHAR(10), '03/05/2013', 101))