ORDER BY can’t be used within subquery

From first glance, this subquery looks absolutely legit. Unfortunately, it won’t work as a subquery but will work as a standalone query. This is why many students failed this question on the exam. The syntax checker doesn’t accept the ORDER BY in the subquery and complaints about missing of the closing parenthesis. And it is easy to verify – just move ORDER BY from subquery to main query and everything will work. This thing worth to be remembered.


Leave a comment

Your email address will not be published. Required fields are marked *