title: How do I make this SQL query work (computed column with nested query)?
body: <p>I want to have a computed column that is true if the field <code>asofdate</code> is equal to the maximum <code>asofdate</code> in the table, otherwise false. I tried the following but I am getting a syntax error. What is the right way to do this?</p>
  
  <pre><code>select 
  case asofdate
  when select max(asofdate) from sometable then 1
  else 0
  end 
  from sometable
  </code></pre>
  
  <p>Alternatively, is it possible to have a computed column along the lines of</p>
  
  <pre><code>case asofdate
  when END OF PREVIOUS MONTH then 1
  else 0
  end
  </code></pre>