Prova così:
codice:set @totale = 0,@tipo = ''; select *,@totale:= if(tipo = @tipo,@totale:=@totale+valore,valore) as cumulato,@tipo:=tipo from tabella order by tipo,periodo
Prova così:
codice:set @totale = 0,@tipo = ''; select *,@totale:= if(tipo = @tipo,@totale:=@totale+valore,valore) as cumulato,@tipo:=tipo from tabella order by tipo,periodo