title: ORDER BY clause is invalid unless TOP or FOR XML is also specified
body: <p>I get "The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified." error with the following code. I initially had two tables, ADSAREAS &amp; CATEGORIES. I started receiving this error when I removed CATEGORIES table.</p>
  
  <pre><code>    Select Case SIDX  
       Case "ID" : SQLCONT1 = " AdsAreasID"
       Case "Page" : SQLCONT1 = " AdsAreasName"
       Case Else : SQLCONT1 = " AdsAreasID"  
  End Select   
  Select Case SORD  
       Case "asc" : SQLCONT2 = " ASC"
       Case "desc" : SQLCONT2 = " DESC"
       Case Else : SQLCONT2 = " ASC"  
  End Select   
  ''# search feature ---&gt;
  Select Case SEARCHFIELD  
       Case "ID" : SQLSFIELD = "AND AdsAreasID"
       Case "Ads Areas" : SQLSFIELD = "AND AdsAreasName"
       Case Else : SQLSFIELD = ""  
  End Select  
  Select Case SEARCHOPER  
       Case "eq" : SQLSOPER = " = " &amp; SEARCHSTRING
       Case "ne" : SQLSOPER = " &lt;&gt; " &amp; SEARCHSTRING
       Case "lt" : SQLSOPER = " &lt;" &amp; SEARCHSTRING
       Case "le" : SQLSOPER = " &lt;= " &amp; SEARCHSTRING    
       Case "gt" : SQLSOPER = " &gt;" &amp; SEARCHSTRING
       Case "ge" : SQLSOPER = " &gt;= " &amp; SEARCHSTRING
       Case "bw" : SQLSOPER = " LIKE '" &amp; SEARCHSTRING &amp; "%' "
       Case "ew" : SQLSOPER = " LIKE '%" &amp; SEARCHSTRING &amp; "' "
       Case "cn" : SQLSOPER = " LIKE '%" &amp; SEARCHSTRING &amp; "%' "
       Case Else : SQLSOPER = ""  
  End Select  
  ''# search feature ---&gt;
  
  SQL = "SELECT * FROM ( SELECT A.AdsAreasID, A.AdsAreasName, ROW_NUMBER() OVER (ORDER BY A.AdsAreasID) As Row"
  SQL = SQL &amp; " FROM ADSAREAS A"
  SQL = SQL &amp; " WHERE Row &gt; ("&amp; RecordsPageSize - RecordsPerPage &amp;") AND Row &lt;= ("&amp; RecordsPageSize &amp;") ORDER BY" &amp; SQLCONT1 &amp; SQLCONT2
  Set objXML = objConn.Execute(SQL)
  </code></pre>