一个简单的统计
日志表TT有字段收款员,收款结果,收款金额,...
现在想统计每个收款员的收款成功次数、金额、收款失败次数、金额,
应该怎么写SQL?
------解决方案--------------------大概就这样:
select 收款员,
sum(收款金额) as "收款金额 ",
sum(decode(收款结果, '成功 ',1,0)) as "收款成功次数 ",
sum(decode(收款结果, '失败 ',1,0)) as "收款失败次数 "
from TT
group by 收款员