Calculate percentage in MySQL

Last Reply 2 months ago By dharmendr

Posted 2 months ago

How to calculate gender percentage from MySQL database in c#

You are viewing reply posted by: dharmendr 2 months ago.
Posted 2 months 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