我正在尝试构建一个 SQL Sum 语句来汇总来自不同表的数据。每个表都有一个共同的 SalesRep 字段。我在弄清楚如何正确构建 SQL 时遇到了一些麻烦。
我知道下面的语法是错误的并且不起作用,但我不是 SQL 专家。我确定这很简单。有人能帮助我吗?
SELECT SalesRepID, SUM(SELECT SalesRepID, Sum(tblClientAdditions.Amount) AS Subtotal
FROM tblClientAdditions GROUP BY SalesRepID + SELECT SalesRepID,
Sum(tblAccounts.ReceivedAmount) AS Subtotal1
FROM tblAccounts GROUP BY SalesRepID) FROM tblSalesReps;