DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`base_ticket`(IN Id_Ticket INT) BEGIN SELECT red(SUM(Cantidad * Preu * (100 - Descuento) / 100)) AS base FROm Movimientos m INNER JOIN Tickets t USING (Id_Ticket) WHERE t.Id_Ticket = Id_Ticket; END$$ DELIMITER ;