Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个查询,我只选择前 10 行,但我有一个 SUM 函数,它仍然取所有行的总和(忽略前 10 行)。如何仅获得前 10 行的总数?这是我的 SUM 函数:
SUM( fact.Purchase_Total_Amount) Total
您是否尝试过使用这样的东西:
SELECT SUM(Whatever) FROM ( SELECT TOP(10) Whatever FROM TableName ) AS T
将 TOP 功能与嵌套查询一起使用
SELECT SUM(innerTable.Purchase_Total_Amount) FROM (SELECT TOP 10 Purchase_Total_Amount FROM Table) as innerTable