How can a review show the average of the other reviews?
EXCLUDE CURRENT ROW removes the current observation from an otherwise defined frame and retains the other eligible observations.
SQLite example and interpretation
Two reviewers scoring two and six each see the other's score. This excludes one row. Deduplicate repeated submissions first if the goal is to exclude a person.
WITH r(id,v) AS (VALUES(1,2),(2,6)) SELECT id,avg(v) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM r ORDER BY id;Result [[1, 6.0], [2, 2.0]]
中文
怎样在每条标注旁计算其他评审的平均分?
EXCLUDE CURRENT ROW 从既定窗口帧移除当前这一行,其他符合帧条件的行仍参与统计。
SQLite 示例与适用条件
两位评审打 2 和 6 分,各自看到另一个人的分数。若同一评审提交多次,这仅排除一行,需先去重才能代表其他人。
WITH r(id,v) AS (VALUES(1,2),(2,6)) SELECT id,avg(v) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM r ORDER BY id;结果 [[1, 6.0], [2, 2.0]]