在SQLite中查找表示一系列总和中特定总和的值

在SQLite中查找表示一系列总和中特定总和的值,sql,sum,Sql,Sum,我已创建了以下表格转角: 这是该表的外观: 我正在尝试检索权重之和=1000的人的姓名 在这种情况下,哪一个是Chillwell或图像中所示的“chill” 我写了以下内容 Select name from turns where weight = (select sum(weight) from turns where sum(weight) = 1000); 这是一个误用错误 Execution finished with errors. Result: misuse of aggrega

我已创建了以下表格转角:

这是该表的外观:

我正在尝试检索权重之和=1000的人的姓名

在这种情况下,哪一个是Chillwell或图像中所示的“chill”

我写了以下内容

Select name from turns where weight = (select sum(weight) from turns where sum(weight) = 1000);
这是一个误用错误

Execution finished with errors.
Result: misuse of aggregate: sum()
At line 1:
Select name from turns where weight = (select sum(weight) from turns where sum(weight) = 1000);
你能给我一些建议吗?

使用累计总和:

select t.*
from (select t.*,
             sum(weight) over (order by turn) as running_weight
      from turns t
     ) t
where running_weight >= 1000 and running_weight - weight < 1000

您应该发布数据,而不是图像请使用您正在运行的数据库标记您的问题:mysql、oracle、sqlserver…?不幸的是,当我将其应用到另一个代码编辑器时,这不起作用。我在附近发现一个语法错误
select t.*
from (select t.*,
             sum(weight) over (order by turn) as running_weight
      from turns t
     ) t
where running_weight >= 1000 and running_weight - weight < 1000