SELECT result, n, round( n / s * 100, 5 ) rat FROM ( SELECT * FROM ( SELECT result, count( 1 ) n FROM sendsms_log GROUP BY result ) t1 INNER JOIN ( SELECT count( 1 ) s FROM sendsms_log ) t2 ON 1 = 1 ) t
Wherein "SELECT result, count (1) n FROM sendsms_log GROUP BY result" message transmission result is packet isolated Statistics, "SELECT count (1) s FROM sendsms_log" number of records of all isolated, round (n / s * 100, 5 ) calculating the percentage, to five decimal places. effect:
result | n | rat |
Extreme | 100 | 10% |
Total generation | 100 | 10% |
Ichiyo | 300 | 30% |
Distribution | 500 | 50% |