mmsql case when 的使用

select CustomerId
,Amount = SUM(Amount)
,InterestAmount = SUM(case when OpType = 1 then Amount else 0 end)
,PrincipalAmount = SUM( case when OpType = 2 then Amount else 0 end)
,TotalCount = Count(0)
from

posted @ 2015-07-20 15:57  haungfeifei  阅读(178)  评论(0编辑  收藏  举报