Calculate Percentage in SQL

From My wiki
Jump to: navigation, search


Formula

there are different ways you can calculate percentage in sql query.

str(((100.0*count(*)) / sum(count(*))), 5, 2)

another way to do the same thing

CAST(ROUND(100.0 * COUNT(*) / tot, 1) AS DECIMAL(10, 1))