How to 'SELECT FROM {entity_bundle} WHERE field_A + field_B <= given_number_X' with EntityFieldQuery $query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'MYCONTENTTYPE')

// Now say for instance I would like to grab the value of
// field_A and field_B, sum them up ( or subtract | divide | multiply them ).
// Then compare the result of that ( is greater than, equals to, smaller than )
// with a given number X. Is it possible with EntityFieldQuery?

$query_result = $query-&gt;execute();


I know I could do that by looping through the query result. Nontheless, if EntityFieldQuery allows me to do that at query time, I would like to know how.
I dont believe you can do this with the core methods provided by the EFQ api.

But, you may always extend the default EFQ class with a version of your own. Or, you may implement a function such as hook_entity_query_alter() or the addTag() method of EFQ.

Using addTag for instance on the EFQ you could then also implement hook_query_TAG_alter() and alter the SelectQuery that is ultimately called from the original EFQ and alter the base query to include your additional (non-standard) logic.

This could look like this short example, we additionally use the SelectQuery::where() method:

// Within some function of yours, you execute your query; giving it a Tag.
$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'MYCONTENTTYPE')
  // Must call the method fieldCondition on field_A and field_B so
  // they get included in the SQL INNER JOIN statement.
  -&gt;fieldCondition('field_A')
  -&gt;fieldCondition('field_B')
  -&gt;addTag('DoFunkyFieldLogic');
$query_result = $query-&gt;execute();

// ... elsewhere in your custom module ...

// Implements hook_query_TAG_alter
function mymodule_query_DoFunkyFieldLogic_alter(QueryAlterableInterface $query) {
  if ($query-&gt;hasTag('DoFunkyFieldLogic')) {
    // You will likely need to install Devel and call dpm($query) here.
    // Or else you wont know what the field names are in the raw SQL ...
    // you might be able to cheat and use full database table names and
    // column names, eg:
    //dpm($query);
    $query-&gt;where("field_data_field_A1.field_A_value + field_data_field_B2.field_B_value &lt;= :my_quantity", array(':my_quantity' =&gt; variable_get('my_quantity', 5));
  }
}


There may be cleaner ways to do this -- but this approach is relatively straight forward. This code is untested; but should work.