答案 0 :(得分:1)
相当复杂,但我认为它有效并可能为您解答
Select sum(`value`) from
(Select
`value`,
@lastval := @lastval + 1 as row_index
from yourtable
cross join (select @lastval := 0) A) B
where B.row_index > (select max(rowindex) from
(Select
`flag`,
@lastval := @lastval + 1 as rowindex
from yourtable
cross join (select @lastval := 0) C) D
where D.flag = 1)
您可以在SQLfiddle
中优化我的答案