declare
@val int = 0;
select
@val = CASE
WHEN MONTH([DATE]) = MONTH(getdate()) AND
YEAR([DATE]) = YEAR(getdate())
THEN SUM(PROFIT)
OVER (PARTITION BY [Name],
MONTH([DATE]), YEAR([DATE]))
ELSE 0
END
FROM table_name
WHERE [Name] = @Name AND
MONTH([DATE]) = @Month AND
YEAR([DATE]) = @Year
print @val