Hi @Lylyy
The final result is still unordered.
Why not move the order by clause to the outside select clause?
The cte(common_table_expression) is just a temporary named result set, it is meaningless to use order by in the definition.
The only effect of TOP 100 percent here is to make SQL server ignore the syntax error. The data of cte result set is still unordered.
Best regards,
Cosmog Hong