sql 多条件求和

select sum(case when mark = 0 then point else 0 end) as Point_0,

sum(case when mark = 1 then point else 0 end) as Point_1,

Account

from 表A

group by Account;

select id

,sum(case when type in (1,2) then [count] else 0 end) as sum1

,sum(case when type in (3) then [count] else 0 end) as sum2

,sum(case when type in (4,5) then [count] else 0 end) as sum3

from 表名

group by id

procFinanceSalaryOrderDetailShow 0504

你可能感兴趣的:(sql)