我一直在处理此SQL语句很长时间,但似乎没有进展。我的数据库中有两个表,一个贷款请求表和一个贷款帐户表,loans-request表存储有关任何贷款请求的信息,而loans-account表存储有关偿还贷款的信息,RequestId为FK表中的cc>。我想从loans-request表中收集所有贷款请求,并将每个贷款与在loans-request表中针对特定请求进行的所有付款的总和结合在一起。我一直在与这个查询作斗争,我不知道该怎么做。我曾尝试张贴一张桌子的图片,但由于声誉而无法我刚刚尝试的SQLSELECT loans-request.*, SUM(loans-account.Amount) FROM loans-request INNER JOIN loans-account on loans-request.requestId = loans-account.requestId谢谢您提供的所有帮助,我的桌子近似视图loans-request table*****************************RequestId | AmountRequested | Active | Approved | SoftDelete |*****************************loans-account table*****************************AccountId| RequestId | Amount| Active | SoftDelete |***************************** (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 SELECT lr.RequestId, SUM(la.Amount) AS AmountPaidFROM LoansRequest lrINNER JOIN LoansAccounts laON lr.RequestId = la.RequestId'GROUP BY lr.RequestId (adsbygoogle = window.adsbygoogle || []).push({}); 10-04 21:36