If you’re getting an error that reads “The function ‘FIRST_VALUE’ must have an OVER clause” in SQL Server, it’s probably because you’re calling the FIRST_VALUE() function without an OVER clause.
The FIRST_VALUE() function requires an OVER clause (and that clause must have an ORDER BY clause).
To fix this issue, be sure to include an OVER clause when calling the FIRST_VALUE() function.