gmc1103 Posted October 23, 2019 Share Posted October 23, 2019 Hello In my query i have x activities, then i have the count of how many still to be executed, i need to get the percentage of the total executed I mean i have 200 activities, 20 have been executed, so i want to have 10% done My query is this one but missing the percentage field SELECT COUNT(*) AS total, IFNULL(SUM(CASE WHEN (t1.dataPrevista >= CURDATE() OR ae.Fim <= CURDATE()) THEN 1 ELSE 0 END),0) AS exec FROM atividades AS t1 INNER JOIN anosescolares AS ae ON (t1.`idAnoEscolar` = ae.idAnoEscolar) WHERE ae.Estado = 1; any help? Quote Link to comment https://forums.phpfreaks.com/topic/309400-getting-percentage-of-calculated-fields/ Share on other sites More sharing options...
Barand Posted October 23, 2019 Share Posted October 23, 2019 Perhaps exec * 100 / total 1 Quote Link to comment https://forums.phpfreaks.com/topic/309400-getting-percentage-of-calculated-fields/#findComment-1570913 Share on other sites More sharing options...
gmc1103 Posted October 23, 2019 Author Share Posted October 23, 2019 Hi Barand Done Thanks Quote Link to comment https://forums.phpfreaks.com/topic/309400-getting-percentage-of-calculated-fields/#findComment-1570914 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.