Getting incorrect syntax near 'FROM', not sure why.. outside of a function this code works fine (provided I change RETURN to SELECT) and gives me the sum of all credits which is a float. Any idea what the problem is?
CREATE FUNCTION [dbo].[getCredits] (@StudentID nchar(10))
RETURNS float
AS
BEGIN
RETURN sum(credits)
FROM kurser c
INNER JOIN student_reg_kurstillfällen ci
ON ci.kurser = c.coursecode
WHERE ci.avslutad_kurs = 1 and StudentID = @StudentID
END