select Aa.Aamount -B.stock , B.bookid from (select sum(A.amount) as Aamount , A.bookid from group by A.bookid ) Aa inner join B on Aa.bookid =B.bookid 上述用的是sql2000 的语法。但都类似。