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 表
+case ic2 when 'o' then qty2 else 0 end
+case ic3 when 'o' then qty3 else 0 end
from 表
不过后面的还没有解答哦:
当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
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 表谢谢,收获很大。