CREATE DEFINER=`root`@`localhost` PROCEDURE `evaluacion_facturas`(IN vfecha DATE)
BEGIN
DECLARE mensaje VARCHAR(50);
DECLARE N_FACTURAS INTEGER;
-- Contar el número de facturas en la fecha dada
SELECT COUNT(*) INTO N_FACTURAS
FROM facturas
WHERE FECHA_VENTA = vfecha;
-- Determinar el mensaje según la cantidad de facturas
IF N_FACTURAS > 70 THEN
SET mensaje = 'Muchas facturas';
ELSE
SET mensaje = 'Pocas facturas';
END IF;
-- Mostrar el número de facturas y el mensaje
SELECT N_FACTURAS AS Numero_de_Facturas, mensaje AS Evaluacion;
END
CALL evaluacion_facturas("2015-01-20");