Abel Pule Chilungu Abel Pule Chilungu - 1 year ago 123
MySQL Question

counting COUNT(*) results in MySQL

I need to count the number of records returned from a MySQL query.

COUNT(sa.facility_hmis) AS deployed
facility_service_area sa
GROUP BY sa.facility_hmis

this will give me lets say 6 rows as the result, but i need it to give me a single row with just the number counted rows i.e 6

Answer Source

Use distinct

SELECT COUNT(distinct facility_hmis) AS deployed FROM facility_service_area
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download