select total=case ic1 when 'o' then qty1 else 0 end
  +case ic2 when 'o' then qty2 else 0 end
  +case ic3 when 'o' then qty3 else 0 end
from 表

解决方案 »

  1.   

    学到东西
    不过后面的还没有解答哦:
    当ic1='o',ic2='o',total=qty1+qty2
    当ic1='o',ic3='o',total=qty1+qty3
    当ic2='o',ic3='o',total=qty2+qty3
    当ic1='o',ic2='o',ic3='o',total=qty1+qty2+qty3
      

  2.   

    我就是用的这个方法:
    select total=case ic1 when 'o' then qty1 else 0 end
      +case ic2 when 'o' then qty2 else 0 end
      +case ic3 when 'o' then qty3 else 0 end
    from 表谢谢,收获很大。