Question: how to calculate percentage in query?
Answer: The most efficient (using over()). select Grade, count(*) * 100.0 / sum(count(*)) over() from MyTable group by Grade. Universal (any SQL version). select Grade, count(*) * 100.0 / (select count(*) from MyTable) from MyTable group by Grade; With CTE, the least efficient.