Agregue tambien para que se cuente cuantas facturas son en total.
USE JUGOS_VENTAS;
DROP PROCEDURE IF EXISTS SUMA_N_FACTURAS;
DELIMITER $$
USE JUGOS_VENTAS$$
CREATE PROCEDURE SUMA_N_FACTURAS(DATE1 DATE, DATE2 DATE)
BEGIN
DECLARE INITDATE DATE DEFAULT DATE1;
DECLARE ACCUMULATE INT DEFAULT 0;
DECLARE TMP INT DEFAULT 0;
WHILE INITDATE <= DATE2
DO
SELECT COUNT(*) INTO TMP FROM FACTURAS WHERE FECHA_VENTA = INITDATE;
SET ACCUMULATE = ACCUMULATE + TMP;
-- SET INITDATE = ADDDATE(INITDATE, INTERVAL 1 DAY);
SELECT CONCAT(DATE_FORMAT(INITDATE,'%d-%m-%Y'), 'TOTAL: ',CAST(TMP AS CHAR(50))) AS RESULTADO;
SELECT ADDDATE(INITDATE, INTERVAL 1 DAY) INTO INITDATE;
END WHILE;
SELECT CONCAT("EL VALOR ACUMULADO DE ", DATE1 ,' A ', DATE2,' ES : ', ACCUMULATE)
AS ACUMULADO;
END$$
DELIMITER ;
CALL SUMA_N_FACTURAS('2017-01-01','2017-01-10');
Saludos