Calculate percentage in MySQL

Last Reply 29 days ago By dharmendr

Posted 29 days ago

How to calculate gender percentage from MySQL database in c#

Posted 29 days ago

Hi Bello,

Check this example.


SELECT Gender, 
CAST((CAST(COUNT(Gender) AS NUMERIC(18,2)) / (SELECT COUNT(*) FROM Employees)) * 100 AS NUMERIC(18,2)) '%'
FROM Employees

Then use the query to display the Percentage.

Refer below article to connect to MySQL database and dipslay the result in GridView.

Connect (Bind) GridView to MySql database in ASP.Net using C# and VB.Net