The entire SQL can be a bit simplified using a plain average;
SELECT Priority,100*AVG(CASE WHEN Bool='True' THEN 1.0 ELSE 0.0 END)
AS '% SLM Met'
FROM Tem
GROUP BY Priority
order by
case Priority
WHEN 'Critical' THEN 1 WHEN 'High' THEN 2
WHEN 'Medium' THEN 3 WHEN 'Low' THEN 4
End;
...or, written in Linq, for example...
var sortArray = new[] {"Critical", "High", "Medium", "Low"};
var result =
(from tem in dbContext.Tem
group tem by tem.Priority
into priorities
select new
{
priority = priorities.Key,
avg = priorities.Average(x => x.Bool == "True" ? 1 : 0)
})
.AsEnumerable()
.OrderBy(x => (Array.IndexOf(sortArray, x.priority)));
As for sorting, this will do the select on the database server and the sorting on the local machine. With this small amount of data, I'd expect that to be faster than complicating the generated SQL.