我有一个简单的select
声明,可以根据我的表格事务对每个地区的经纪人费用进行分组。
SELECT brokerid AS Broker, sum(brokersfees) AS Fees
FROM transactions
WHERE handelstag>#1/1/2014#
and regionid = 1
GROUP BY brokerid;
区域1的结果如下:
broker fees
1 2540
55 26698
882 100000
现在我希望在这个区域的所有经纪人身上得到这个结果的总和。因此增加1,55,882等费用
我这样做了:
SELECT SUM(Fees) AS ALLIN FROM
(
SELECT brokerid AS Broker, sum(brokersfees) AS Fees
FROM transactions
WHERE handelstag>#1/1/2014#
and regionid = 1
GROUP BY brokerid;
) AS t
我确实得到了一个结果,但它太高了。我手动添加结果时确认了这一点。 我错过了什么?