Delimiter //
create function fn_calcular_subtotal(_cantidad int, _precio int)
returns int
BEGIN
declare subtotal int;
set subtotal= (select sum(_Cantidad*_Precio) from producto join detalle_pedido on ID_Producto = Producto where ID_Producto = Producto);
return fn_calcular_subtotal();
END//