• got this error:

    Windowed functions can only appear in the SELECT or ORDER BY clauses.