select s.name AS "Segment Name", count(se_segment_contacts_1contacts_idb) AS "Count Related Contacts"  FROM se_segment_contacts_1_c, se_segment s WHERE s.id = se_segment_contacts_1_c.se_segment_contacts_1se_segment_ida AND s.deleted =0 AND se_segment_contacts_1_c.deleted = 0 AND se_segment_contacts_1contacts_idb IN (select id from contacts WHERE deleted = 0) GROUP BY se_segment_contacts_1se_segment_ida HAVING count(se_segment_contacts_1contacts_idb) >0 ORDER BY s.name ASC;