测试select * from useraddmoney a left join (select username,sum(money) money from useraddmoney group by username) b on a.username=b.username where b.money>=a.tolpay
and not exists(select 1 from userinfo where username=a.username) and a.isok=1
and not exists(select 1 from userinfo where username=a.username) and a.isok=1
group by username,tolpay
having(sum(money)>=tolpay and username not in (select username from tab2))
group by username,tolpay
having(sum(money)>=tolpay and username not in (select username from tab2) and isok=1)