select abs(sum(Case When b.return_type = 2
Then b.box_count Else 0 End)) as collect_count,
sum(Case When b.return_type=0
Then b.box_count Else 0 End) as return_count,
sum(Case When b.return_type=1
Then b.box_count Else 0 End) as in_count
,r.name,r.tel from box_records as b inner join roles as r on b.role_id=r.id
group by b.role_id;
网友评论