select username,发送数=count(1),成功数=sum(case when Send_out=2 then 1 else 0 end),失败数=sum(case when Send_out=3 then 1 else 0 end) from table1 group by username
select username, [发送数]=count(1), [成功数]=sum(case when Send_out=2 then 1 else 0 end), [失败数]=sum(case when Send_out=3 then 1 else 0 end) from tb group by username
[发送数]=count(1),
[成功数]=sum(case when Send_out=2 then 1 else 0 end),
[失败数]=sum(case when Send_out=3 then 1 else 0 end)
from tb
group by username