I think you will have to use dynamic SQL
declare @strSql nvarchar(100)
declare @count int
select @count = COUNT(*) from tblMyTable where ID = 1
set @strSql ='select ' +
case @count when 1 then ' ColA '
else 'MAX(ColA)' end
+ 'from tblMyTable '
+ 'group by ' + case @count when 1 then ' ColA '
else ' ColB ' end
sp_executesql @strSql