title: Use Union All & Order By In View?
body: <p>I need to order by a date column contained in both of my tables in my view.  Below is the syntax I use for my view, but if I try to use the order by statement in the view I get this error:</p>
  <blockquote>
  <p>Msg 1033, Level 15, State 1, Procedure TransFund_Lead_Upload_File, Line 63</p>
  <p>The ORDER BY clause is invalid in views, inline functions, derived tables, and   subqueries, unless TOP is also specified.</p>
  </blockquote>
  <p>This is my query syntax..what needs to be altered so that I can order by [Follow Up] Desc?</p>
  <pre><code>SELECT * FROM
  (
  Select
  'abcd' As [P]
  ,ISNULL(Building_Name,'') As [Building_Name]
  ,ISNULL(ID,'') As [Record ID]
  ,ISNULL(city,'') + ', ' + ISNULL([state],'') As [Zone]
  ,ISNULL(CONVERT(VARCHAR(10), [Sale Date], 101),'') As [Actual Sale Date]
  ,'' As [Begin Effort]
  ,ISNULL(CAST(sold_items AS VARCHAR(500)),'') As [Items List]
  ,ISNULL(CAST(wascoreItemSold AS Varchar(500)),'') As [Info]
  ,ISNULL(CONVERT(VARCHAR(10), followupdate, 101),'') As [Follow Up]
  FROM dbo.esrt b
  UNION ALL
  Select
  'eeee' As [P]
  ,ISNULL(Building_Name,'') As [Building_Name]
  ,ISNULL(ID,'') As [Record ID]
  ,ISNULL(city,'') + ', ' + ISNULL([state],'') As [Zone]
  ,ISNULL(CONVERT(VARCHAR(10), Sale Date, 101),'') As [Actual Sale Date]
  ,'' As [Begin Effort]
  ,ISNULL(CAST(sold_items AS Varchar(500)),'') As [Items List]
  ,ISNULL(CAST(wascoreItemSold AS Varchar(500)),'') As [Info]
  ,ISNULL(CONVERT(VARCHAR(10), followupdate, 101),'') As [Follow Up]
  FROM dbo.foxtrot a
  ) a
  ORDER BY a.[Follow Up] DESC
  </code></pre>