Mysql
 sql >> Database >  >> RDS >> Mysql

restituiscono righe in cui somma su un campo inferiore a un determinato valore

set @total:=0;
select id, name, value, `order`
from 
(select 
 id, name, value, `order`, 
 @total:=if(@total is null, 0, @total)+`order` as total
 from THE_TABLE
 order by `order`
) as derived 
where total<=30;