Using db_select to only get the latest nodes with a certain field value
You might try something like :

$query = db_select('node', 'n');
$query-&gt;join('content_type_nodetype', 'ct', 'ct.nid = n.nid');
$query-&gt;groupBy('field_someid_value');
$query-&gt;addExpression('MAX(n.nid)', 'nid');


The 'nid' order must follow the 'created' order so you won't need to order the results. Just taking the biggest nid for each field_someid_value should do the job.