silly mistake, forgot $wpdb
, it should be
$school_count_last_month = $wpdb->get_var("SELECT COUNT(*) from $wpdb->posts where post_date >= DATE_ADD(LAST_DAY(DATE_SUB(NOW(),INTERVAL 2 MONTH)),INTERVAL 1 DAY) and post_date <= DATE_SUB(NOW(),INTERVAL 1 MONTH)");