Hello All!

I have a MySQL database with 4 items, id (numerical), group_name, employees, and surveys.

I need to in my select calulate the percentage of 'employees' who my the number in 'surveys' have taken the survey.

This is the statement I have now:

SELECT group_name, employees, surveys, COUNT( surveys ) AS percentage, 
            ((COUNT( * ) / ( SELECT COUNT( * ) FROM db_test)) * 100 ) AS percentage
        FROM db_test
        ORDER BY surveys
Re: MySQL Calculate Percentage 80 80

So lets get this right and clarify, are you saying for instance if the total No of employees is 100,
and the total No of surveys is 50, you want an answer of 50% ??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.