IF you use php and mysql combine it like so:
$find = $db->prepare("SELECT count(id) as countaggre FROM analytics_aggregate"); $find->execute(); $countaggregates = $find->fetch(PDO::FETCH_ASSOC); if($countaggregates['countaggre'] > 12) { $start = $countaggregates['countaggre'] - 12; } else { $start = 0; } $find = $db->prepare("SELECT * FROM analytics_aggregate ORDER BY id ASC LIMIT ".$start.", 12");