You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', '-', 2)), '-', -1) AS mes, COUNT(*) AS totalOpes, SUM(presupuesto)AS facturaci' at line 1