title: sql complex case when statement for a calculated field
body: <p>I need help for this complex sql statement. In a select query, I need to add a statement to a calculated field with this structure:</p>
  
  <pre><code>If Field1 = 'value1' then
  
  
  If Field2 = 0 then FCalculated1 = FieldA * FieldB
  
  else FCalculated1 = FieldA * FieldC
  
  end
  
  FCalculated2 = FCalculated1 * FieldA
  
  
  else if Field1 = 'value2' then
  
  
  If Field2 = 0 then FCalculated2 = FieldD * FieldB
  
  else FCalculated2 = FieldD * FieldE
  
  end
  
  FCalculated1 = FCalculated2 / FieldA
  
  
  end
  </code></pre>
  
  <p>Basically I need to nest one conditional within another and use a calculated field as the source of another field.  Does anyone can help me?</p>
  
  <p>Thank you!!!</p>