日期:2014-05-18 浏览次数:20684 次
select @username1,@uermoney1,b_after
from bank_back AS a
INNER JOIN (select top 1 b_after from bank_back where username=@username1 and addtime<'11-11-1 17:47' order by addtime desc) AS b ON a.username=b.username
INNER JOIN (select sum(back_money2)-sum(back_money) AS back_money from bank_back where username=@username1 and addtime>'11-11-1 17:47' and follows not like '%hedui%' and follows not like '修改资金') AS c ON c.username=a.username
WHERE b.b_after <>@uermoney1-c.back_money
------解决方案--------------------
直接查询不行吗
select a.username,a.uermoney1,b.b_after
from users a,bank_back b
where a.username=b.username
and uermoney1<>
(select (select sum(back_money2)-sum(back_money) from bank_back where username=b.username1 and addtime>'11-11-1 17:47'
and follows not like '%hedui%' and follows not like '修改资金')+(select top 1 b_after from bank_back where username=b.username1 and addtime<'11-11-1 17:47' order by addtime desc)