title: How can I write nested CASE statement based on query below?
body: <p>I am using <code>CASE</code> statement to create column <code>Quoted</code>. So its gonna display value 1 or 0. </p>
  
  <p>But then column <code>DisplayStatus</code> have to be created based on the condition of previous column <code>Quoted</code>.</p>
  
  <p>Seems like I should use nested CASE statement in this situation. But I cannot come up with right query.</p>
  
  <pre><code>SELECT 
         case when isnull(grouptt.controlno,0) &lt;&gt;0 AND  isnull(vwR.Premium,0) &gt; 0 then 
        cast( 1 as bit)
        else cast( 0 as bit)
        end as Quoted,
  
        CASE 
             WHEN a.DisplayStatus = 'LOST' AND quoted=1  THEN 'Quoted_Lost'
             WHEN a.DisplayStatus = 'DECLINED' AND quoted=1  THEN 'Quoted_NotTakenUp'
             WHEN a.DisplayStatus = 'NOT TAKEN UP' AND quoted=1  THEN 'Quoted_Lost'
             ELSE
                    a.DisplayStatus
        END
        DisplayStatus
      FROM MyTable 
  </code></pre>