title: Select a value by the latest dateTime value in SQL Server2008
body: <p>I have table in SQL Server as below. Table Name: LANDS</p>
  
  <pre><code>Land_ID   UID             DM_DATE              DEL_REASON
     1       5     2013-05-21 20:31:53.773        Reason1
     1       1     2013-05-21 20:45:21.610        Reason2
     1       1     2013-05-21 20:45:27.613        Reason3
  </code></pre>
  
  <p><strong>I want to get the DEL_REASON for the latest DM_DATE (get the value of reasons for the last entered date), means (Reason3).</strong></p>
  
  <p>I wrote this select statement, but it gives me this error <code>"An expression of non-boolean type specified in a context where a condition is expected, near ')'"</code></p>
  
  <pre><code>select [DEL_REASON] from [LANDS] where [Land_ID]='1' AND [UID] ='1' AND MAX([DM_DATE]) 
  </code></pre>
  
  <p>Can someone help.   </p>