SQL : count percent of each values

Viewed 30

I have a table called Orders, column and values of table.

Column [Order Priority] can have one of 4 values: Critical, High, Medium, Low. Ship_tt can have one of 3 values: Som, Tre, Dung.

I want to calculate percentage 'Som','Tre','Dung' of Critical, High, Medium, Low.

Thanks for your help.

1 Answers
SELECT ORDER_PRIORITY, 100. * COUNT(*) / SUM(COUNT(*)) OVER ()
FROM @T T
GROUP BY ORDER_PRIORITY
Related