Share via


2.1.2.116 F851, <order by clause> in subqueries

V0152:

The specification states the following:

 Subclause 7.13, "<query expression>":
  
 <query expression> ::=
 [ <with clause> ] <query expression body>
 [ <order by clause> ] [ <fetch first clause> ]
  
 ...
  
 <order by clause> ::=
 ORDER BY <sort specification list>
  
 ...
  
 Conformance Rules
  
 Without Feature F851, "<order by clause> in subqueries", in conforming SQL language, a <query expression> contained in another <query expression> shall not immediately contain an <order by clause>.
  

Microsoft SQL Server 2008 R2 and Microsoft SQL Server 2012 vary as follows:

Transact-SQL partially supports this feature. The ORDER BY clause is not valid in subqueries unless a TOP clause is also specified.