0

I would like to calculate named "Success Rate" with this 2 query in one table.

The First is

SELECT sum(`session count`) as success 
FROM itsqm_trubex._d_itqsm_tmenu 
where `statusCode` in ('00000000', '00008006');

The Second is

SELECT sum(`session count`) as total FROM itsqm_trubex._d_itqsm_tmenu;

How to write query if i want the result is (success / total) * 100%?

Shadow
  • 33,525
  • 10
  • 51
  • 64
trubex
  • 139
  • 1
  • 2
  • 7
  • https://stackoverflow.com/questions/15746749/mysql-calculate-percentage – Rahul Mahadik Mar 13 '18 at 06:44
  • `SELECT SUM(SESSION COUNT) AS total,(SELECT SUM(SESSION COUNT) AS success FROM itsqm_trubex._d_itqsm_tmenu WHERE statusCode IN ('00000000', '00008006')) AS success,((SELECT SUM(SESSION COUNT) AS success FROM itsqm_trubex._d_itqsm_tmenu WHERE statusCode IN ('00000000', '00008006')/SUM(SESSION COUNT))*100 AS Percentage FROM itsqm_trubex._d_itqsm_tmenu;` – Aishwarya Mar 13 '18 at 06:55
  • @Aishwarya: That is not a comment, but an attempt at an answer. Please post it as an answer, not a comment. – KIKO Software Mar 13 '18 at 07:04
  • i am not getting any answer tab here . so, i commented here – Aishwarya Mar 13 '18 at 07:10

0 Answers0