title: how should i validate if one datetime field is greater then second datetime in sql server 2008 using IF else statement?
body: <p>I'm writing a sql query in which i want to check if one datetime field from table a is greater then a datetime field in table b.</p>
  
  <p>Any help would be appriciated.</p>
  
  <p>My query looks something like this:</p>
  
  <pre><code>SELECT A.AFIELD, B.BFIELD, ( &lt;HERE I WANT TO PUT THE VALIDATION STATEMENT&gt; ) AS 'VALIDATED AS' FROM A JOIN B ON A.AFIELD=B.AFIELD
  </code></pre>
  
  <p>Validation statement should be like</p>
  
  <pre><code>If (A.XFIELD &lt; B.YFIELD)
  THEN "YES"
  ELSE
  "NO"
  </code></pre>
  
  <p>I'm trying it but not able to do so, it will be greatful if, anybody can help.</p>