If you’re getting an error that reads “The function ‘DENSE_RANK’ must have an OVER clause with ORDER BY” in SQL Server, it’s probably because you’re calling the DENSE_RANK()
function without an ORDER BY
clause.
Window functions such as DENSE_RANK()
require an OVER
clause, and that clause must have an ORDER BY
clause. If you’re getting the above error, it’s likely that you’re providing an OVER
clause, but you’re omitting the ORDER BY
clause.
To fix this error, add an ORDER BY
clause to the OVER
clause.