Found this link that solved my problem:
https://wordpress.stackexchange.com/questions/10988/disallow-categories-from-this-mysql-query
$tax_query = array ( array( 'taxonomy' => 'category', 'terms' => array ( 8 ), 'operator' => 'IN' ) );
$clauses = get_tax_sql ( $tax_query, $wpdb->posts, 'ID' );
$results = $wpdb->get_results
(
"SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', count(ID) as posts
FROM $wpdb->posts {$clauses['join']}
WHERE post_type = 'post'
AND post_status = 'publish'
{$clauses['where']}
GROUP BY YEAR(post_date), MONTH(post_date)
ORDER BY post_date DESC"
);
Basically it provides the mySQL query for the JOIN part and the WHERE statements. In my case I change ‘operator’ => ‘NOT IN’ to ‘operator’ => ‘IN’