CREATE OR REPLACE PROCEDURE stp_paretoStatus(
	IN machine_id INT,
	IN dt_from DATETIME,
	IN dt_to DATETIME
)
READS SQL DATA
BEGIN
	SELECT	CodStatus, SUM(Duration) AS TotDuration
	FROM		StatusLog
		WHERE	MachineId = machine_id
		AND	DtRif >= dt_from 
		AND	DtRif <= dt_to	
	GROUP BY CodStatus;
END;