<?php
if (empty($wp)) {
require_once('wp-config.php');
}
global $wpdb;
$data = $wpdb->get_results(
"SELECT
YEAR(p.post_date),
count(*) counter
FROM
wp_posts p
WHERE
p.post_status = 'publish'
AND p.post_type = 'post'
GROUP BY
YEAR(p.post_date)
ORDER BY
YEAR(p.post_date)
");
print_r($data);