title: sql server The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions
body: <pre><code>    SELECT TOP 28 *
      FROM (
          SELECT DISTINCT [DATECOL]
              ,[CODE ARTICLE]
              ,[CODE SITE]
              ,[CODE STRUCTURE]
          FROM [VENTE] T2
          WHERE PROMO = 0
              AND ([CODE ARTICLE] IS NOT NULL)
              AND ([CODE STRUCTURE] IS NOT NULL)
              AND ([PRIX DE REVIENT] IS NOT NULL)
              AND [CODE ARTICLE] = '    714180291'
              AND [CODE SITE] = '    7'
          ORDER BY [DATECOL]
          ) T
  </code></pre>
  
  <p>I got the following error </p>
  
  <blockquote>
    <p>Msg 1033, Level 15, State 1, Line 9 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.</p>
  </blockquote>
  
  <p>How to correct it ?</p>