Is this Sugarquery
$sugarQuery = new SugarQuery();
$sugarQuery->select(array('id'));
$sugarQuery->from(BeanFactory::newBean('Contacts'));
$sugarQuery->whereRaw("NOW() >= DATE_SUB(dt_previsao_relacionamento_c, INTERVAL 1 HOUR)");
$sugarQuery->where()->notEquals('dt_previsao_relacionamento_c', '0000-00-00 00:00:00');
$sugarQuery->where()->isNotEmpty('dt_previsao_relacionamento_c');
$sugarQuery->where()->notNull('dt_previsao_relacionamento_c');
$values = array('Expirada');
$sugarQuery->where()->in('fases_relacionamento_c',$values);
$values = array('Online');
$sugarQuery->where()->notIn('lftm_segmentacao_cliente_c',$values);
$sugarQuery->where()->equals('lftm_status_cliente_c','Ativo');
$sugarQuery->where()->equals('deleted',0)
Equivalent to this query?
$sql = "SELECT IFNULL(contacts.id,'') primaryid
FROM contacts LEFT JOIN contacts_cstm contacts_cstm ON contacts.id = contacts_cstm.id_c
WHERE NOW() >= DATE_SUB(contacts_cstm.dt_previsao_relacionamento_c, INTERVAL 1 HOUR)
AND contacts_cstm.dt_previsao_relacionamento_c IS NOT NULL
AND contacts_cstm.dt_previsao_relacionamento_c <> '0000-00-00 00:00:00'
AND contacts_cstm.fases_relacionamento_c NOT IN ('Expirada')
AND contacts_cstm.lftm_segmentacao_cliente_c NOT IN ('Online')
AND contacts_cstm.lftm_status_cliente_c = 'Ativo'
AND contacts.deleted=0;";