How do you convert to percentage by using COUNT in SQL? -
for example, if want list percentages of males , females in 'employee' table. right?
select sex, count (sex) [%] employees group sex; and if want list gender less 50%? following correct?
select sex, count (sex) [%] employees group sex having count (sex) < 50% thank you.
i believe you're looking for.
select sex, (count(sex)* 100 / (select count(*) employees)) mypercentage employees group sex then can do
having mypercentage < 50
Comments
Post a Comment