Is there an easier way of grouping with this type of query?
Select Distinct
left(TrackerFileName,38),
(Select Count(AccountNo) from DTVSummary where Active = 'N' and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Not_Active,
(Select Count(AccountNo) from DTVSummary where Active = 'Y' and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Active,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 1 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H' ) as Acct1,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 2 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct2,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 3 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct3,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 4 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct4,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 5 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct5,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 6 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct6,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 7 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct7,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 8 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct8,
(Select Count(AccountNo) from DTVSummary where AttemptQty = 9 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct9,
(Select Count(AccountNo) from DTVSummary where AttemptQty >=10 and TrackerFileName = 'FC200608267912.CompMkt_Cvs3H') as Acct10
From DTVSummary
where TrackerFileName = 'FC200608267912.CompMkt_Cvs3H'
group by TrackerFileName
go