Add expression db_select
That would need a combination of SelectQuery::addExpression(), and SelectQuery::having(), e.g.

$query = db_select('tn_api_users', 'u')
  -&gt;fields('u', array('row_id', 'name', 'email'))
  -&gt;groupBy('name')
  -&gt;having('name_count &gt; 1');

$query-&gt;addExpression('COUNT(name)', 'name_count');


Output:

SELECT u.row_id AS row_id, u.name AS name, u.email AS email, COUNT(name) AS name_count
FROM 
{tn_api_users} u
GROUP BY name
HAVING  (name_count &gt; 1)