title: How to use else-if condition in a view in SQL server?
body: <p>I know that an <em>if</em> condition can be achieved using the <code>CASE</code> statement:</p>
  
  <pre><code>CASE
      WHEN &lt;condition&gt;
          x
      ELSE
          z
  END
  </code></pre>
  
  <p>but how to do that for an <em>else-if</em> condition?</p>
  
  <p>Something like this (pseudo code):</p>
  
  <pre><code>CASE
      WHEN &lt;condition&gt;
          x
      ELSE-IF &lt;condition&gt;
          y
      ELSE
          z
  END
  </code></pre>
  
  <p>My code as of now:</p>
  
  <pre><code>CREATE VIEW [dbo].[v_myview1]
  AS
      SELECT 
          ci.aDate, ci.Currency, ci.lim, ci.LimitUS,
          pa.Date as AmtDate,
          pa.Payment as AmtPayment,
          CASE 
              WHEN (ci.aDate - pa.Date) &lt; 0 THEN ci.LimitUS
              --ELSE IF
              --WHEN (ci.lim - pa.Payment) &lt; 0 THEN 'a'
              ELSE 'b'
          END AS Estimate,
      FROM
          dbo.Amt pa
      JOIN 
          dbo.CrInfo ci ON ci.pr_key = pa.pr_key
      JOIN
          dbo.rates tr ON rt.Currency = ci.Currency 
      WHERE 
          ci.mk = 2
  </code></pre>