This code generates the following error:
Msg 156, Level 15, State 1, Total ProcedureOrder Order, Line 7 Incorrect syntax near the keyword 'FROM'.
CREATE FUNCTION dbo.totalGastoPedido(@id_mesa int)
RETURNS int
AS
BEGIN
DECLARE @Total money
SET @Total = (SELECT SUM(ped.ValorPagar))
FROM Pedido ped
where @id_mesa = IdMesa
and ped.Data>'2016-02-10' and ped.Data<'2016-02-10'
RETURN @Total
END