ORDER BY is not allowed in SUBQUERY

It does not make any sense to sort data before passing them to an outer query from inner query.  The subquery will be used in some outer query, and that outer query will have to do ordering anyway, so there’s no point ordering the subquery. The outer query will print the result in no particular order unless ORDER BY was used in the outer query. But even if you use the ORDER BY clause in the outer query, this order would differ from the order supplied by the inner query. So, it does not make any sense to sort the data inside the inner query, because the outer query won’t use that order anyway. The outer query will use its own ORDER BY clause which will force the data to be sorted or it will print the data in no particular order if no ORDER BY query was used in the outer query.

Therefore when you try to sort data within the subquery, it always returns error.

 

If you remove the ORDER BY clause from the inner query and put the right parenthesis on line 1310 as it says, then it will run without any error.

 

 

Leave a comment

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