Use CASE inside COUNT.
ELSE case implies NULL, which is ignored by COUNT(column)
SELECT u.*, count(CASE WHEN c.status = 'A' THEN c.id END) as total_active, COUNT(c.id) AS total FROM `users` u LEFT JOIN `classifieds` c ON c.user_id = u.id GROUP BY u.id
In addition, standard SQL is to group or group columns: MySQL GROUP BY extensions can produce misleading results because the engine guesses what you want.
Try this query with SET SQL_MODE = 'ONLY_FULL_GROUP_BY' to find out what I mean ...
source share