Error: During executing the SQL Server Query by using Order by clause inside subquery is getting the following error:
select * from (select * from [Person].[CountryRegion] order by 1) k
Msg 1033, Level 15, State 1, Line 2
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.
Solution:
We are using order by in subquery, we can do the alternative by placing order by clause in outside query as:
select * from (select * from [Person].[CountryRegion]) k order by 1