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 >= 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->select('request')
->fields('request', array('Count(requestID)'))
->condition('dateCreated','DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)', '>=')
->condition('ek_borrowerID','111')
->execute();
Database::setActiveConnection();