CREATE TABLE my_table
(item_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, amount INT NOT NULL);
INSERT INTO my_table VALUES (NULL,50);
INSERT INTO my_table VALUES (NULL,50);
INSERT INTO my_table VALUES (NULL,50);
SELECT * FROM my_table;
+---------+--------+
| item_id | amount |
+---------+--------+
| 1 | 50 |
| 2 | 50 |
| 3 | 50 |
+---------+--------+
SELECT x.*
, SUM(y.amount) rt
FROM my_table x
JOIN my_table y
ON y.item_id <= x.item_id
GROUP
BY x.item_id;
+---------+--------+------+
| item_id | amount | rt |
+---------+--------+------+
| 1 | 50 | 50 |
| 2 | 50 | 100 |
| 3 | 50 | 150 |
+---------+--------+------+
SELECT x.*
, CASE WHEN SUM(y.amount) < 120 THEN 1 ELSE 0 END paid
FROM my_table x
JOIN my_table y
ON y.item_id <= x.item_id
GROUP
BY x.item_id;
+---------+--------+------+
| item_id | amount | paid |
+---------+--------+------+
| 1 | 50 | 1 |
| 2 | 50 | 1 |
| 3 | 50 | 0 |
+---------+--------+------+
请注意,在您的情况下,您可能对已经“支付”的评估结果不太感兴趣。