<?php
$dates = $wpdb->get_results( "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit" );
foreach ($dates as $value) {
echo $value->year . " - ";
echo $value->posts . "<br>";
};
unset($dates);
?>