仅前 10 行的总和 [英] SUM of only TOP 10 rows
本文介绍了仅前 10 行的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个查询,我只选择前 10 行,但我在那里有一个 SUM 函数,它仍在计算所有行的总和(不考虑前 10 行).如何仅获得前 10 行的总数?这是我的 SUM 函数:
I have a query where I am only selecting the TOP 10 rows, but I have a SUM function in there that is still taking the sum of all the rows (disregarding the TOP 10). How do I get the total of only the top 10 rows? Here is my SUM function :
SUM( fact.Purchase_Total_Amount) Total
推荐答案
你是否尝试过使用这样的东西:
Have you tried to use something like this:
SELECT SUM(Whatever)
FROM (
SELECT TOP(10) Whatever
FROM TableName
) AS T
这篇关于仅前 10 行的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文