question

vijay559 avatar image
vijay559 asked

What percentage of male students were freshmen?

I need the query for this please help me! Here classification is a field and the data type is numeric. Classification: 1 =>Freshman 2=>Sophmore 3=>Unclassified 4=>Associate Degree 5=>Bachelor 6=>3rd Year Bachelor 7=>4th Year Bachelor
sqlhomework
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
ruancra avatar image
ruancra answered
Select Classification ,count(Classification) ,CONVERT(DECIMAL(4,2),(Count(Classification)* 100.0 / (Select Count(*) From YourTable))) as Percentage From YourTable Group By Classification
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.