diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index f38c5ad421..65504af03d 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -143,7 +143,7 @@ class addressbook_sql extends so_sql if (!$by) { $extra = array( - 'COUNT(org_name) AS org_count', + 'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count', "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count", "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count", ); @@ -158,7 +158,7 @@ class addressbook_sql extends so_sql parent::search($param['search'],array('org_name'),$append,array( "NULL AS $by", '1 AS is_main', - 'COUNT(org_name) AS org_count', + 'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count', "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count", "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count", ),'%',false,'OR','UNION',$filter); @@ -167,7 +167,7 @@ class addressbook_sql extends so_sql parent::search($param['search'],array('org_name'),$append,array( "CASE WHEN $by IS NULL THEN '' ELSE $by END AS $by", '0 AS is_main', - 'COUNT(org_name) AS org_count', + 'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count', "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count", "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count", ),'%',false,'OR','UNION',$filter);