A subquery, view or common table expression is ordered without a row limit, so the order is lost
What it finds
SELECT * FROM (SELECT ... ORDER BY x) t: a subquery's ORDER BY without a row limit orders nothing the outer query keeps. Tables have no order, the outer query may return the rows in any order, and SQL Server rejects it. The order belongs to the outer query.
Subqueries with TOP, LIMIT, FETCH or FOR XML, which use the order to choose or shape rows, are left alone, and so are array constructors, which keep it, and Oracle, whose ROWNUM filters rely on it.
From the rule's source, order_by_in_subquery.rs.
Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/sql:order-by-in-subquery" = "warning"To keep one finding, suppress it with a reason: tx0 suppress ID --reason "..." writes the comment for it.
tx0 explain tx0/sql:order-by-in-subquery shows the same in the terminal. Found a false positive? Report it.