Cannot process SQL count totals query