Friday 15 July 2011

sql server - Getting the greater of two values in SQL -


I have a SQL Server table. This table has two tables: Order and order in progress Both tables have similar structures :

  order [incompressed] ----------------- ID (unique identity) CreateDate ...   < P> I need to get the latest order or order impression  
  DECLARE @latestOrderID uniqueidentifier @latestOrderID =?   

How do I set up the most recent order or OrderInProgress ID @latestOrderID? I can not understand how to do this in SQL.

Thank you!

Try it, which should be more efficient whenever it counts more.

  Select the top 1 ID from the order order by IDE union. OrderInprogress ID details) T order based on ID    

No comments:

Post a Comment