How to query external database for Count How do I query the below SQL query to an external database table from Drupal 8 custom module, 

Select Count(requestID) FROM requestDB.request where request.dateCreated &gt;= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) and ek_borrowerID = 111;


I have configured the settings.php already. Below is the query I tried to build, but it does not work 

Database::setActiveConnection('requestDB');
$db = Database::getConnection();
$db-&gt;select('request')
    -&gt;fields('request', array('Count(requestID)'))
    -&gt;condition('dateCreated','DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)', '&gt;=')
    -&gt;condition('ek_borrowerID','111')
    -&gt;execute();
Database::setActiveConnection();
You need to use ->addExpression() instead of ->fields()