下点功夫,钻研!!!
一个查询句子
/*查询账目不对的人的用户表+缴费表*/
select
B.StuId,
A.StuName as 用户, sum(B.ShouldPay) as '应交款' ,
sum(B.Paid)+sum(B.Preferential)+sum(B.Owe) as '加起来以后',
sum(B.Paid) as '实交',
sum(B.Preferential) as '优惠',
sum(B.Owe) as '欠款'
from StudentInfo as A inner join StudentPayment as B on A.StuId=B.StuId
group by A.StuName,B.StuId having sum(B.ShouldPay)<>sum(B.Paid)+sum(B.Preferential)+sum(B.Owe)