title: case when with multiple conditions in mysql
body: <pre><code>CASE WHEN (D.BUYQ&gt;0 AND D.SELLQ&gt;0 AND D.series_expiry='2050-01-01') then
   sum(D.stt_INTRA_buy*least(D.buyq,D.SELLQ)*D.buyavg)+sum(D.stt_buy*(D.buyq-least(D.buyq,D.SELLQ))*D.buyavg) 
  ELSE
  sum(D.stt_buy*D.buyq*D.buyavg) 
   END) as xsttbuy
  </code></pre>
  
  <p>The case condition always held's False and it enters into else even after data being there in the database which satisfies the True condition.</p>